我在窗口手机8.0上工作,我在尝试从移动电话向网站提交发布请求时遇到了问题。输入名为“文件”,它只接受图像文件。窗口电话8提交图像形式
<form action="upmeme" method="post" enctype="multipart/form-data">
<input type="file" class="file" name="file" id="file"><br>
<input type="submit" class="submit" name="submit" value="Submit">
</form>
,或者你可以在这里老朋友:this website
我用PhotoPicker可供选择libary照片,并将其保持到“照片” Stream photo = e.ChosenPhoto;
它完美地工作。
现在我需要上传照片,并提交以上。这形式是我的代码调用来发送POST请求,但它不工作,响应相同登顶
photo.Position = 0;
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(url);
HttpRequestMessage request = new HttpRequestMessage();
MultipartFormDataContent form = new MultipartFormDataContent();
form.Add(new StreamContent(photo),"file");
HttpResponseMessage response = await client.PostAsync(url, form);
string responseBodyAsText = await response.Content.ReadAsStringAsync();
我之前试图在互联网周围寻找,我发现与我的相同的结果。我的代码在某处错了吗?
我已经实现了一些简单的HTTP类上传文件,看看http://mytoolkit.codeplex.com/wikipage?title=Http,章节“HTTP POST” – 2014-12-15 15:33:05