creating a webservice that accepts a file (Stream) doesnt want other params

前端 未结 6 1493
梦毁少年i
梦毁少年i 2021-01-13 22:50

I have a File i want to upload to a Webservice, but it needs additional params, so I create some hidden fields with the associated name:value pairs to get pushed to the serv

6条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-13 23:02

    When you send a stream, it will actually send everything in the request. I did this to get the data:

    public string NewImage(Stream data){
        NameValueCollection PostParameters = HttpUtility.ParseQueryString(new StreamReader(data).ReadToEnd());
        string server = PostParameters["server"],
        string datasource = PostParameters["datasource"], 
        string document = PostParameters["document"];
        string image_id = PostParameters["image_id"];
        var img = PostParameters["File"];
    
        //do other processing...
    }
    

提交回复
热议问题