说真的,我搜索了很多从 WP8 上传到服务器的文件。它不起作用:(
为什么我得到这个错误?这是错误是因为我的 FileuploadUrl?
System.Net.Http.HttpRequestException:响应状态码不表示成功:405(不允许方法)
private async void UploadFile()
{
try
{
if (photoStream != null)
{
//var fileUploadUrl = @"http://<IPaddress>:<port>/fileupload";
var fileUploadUrl = @"http://www.comevox.com:80/services";
var client = new HttpClient();
photoStream.Position = 0;
MultipartFormDataContent content = new MultipartFormDataContent();
content.Add(new StreamContent(photoStream), "file", fileName);
await client.PostAsync(fileUploadUrl, content)
.ContinueWith((postTask) =>
{
postTask.Result.EnsureSuccessStatusCode();
});
}
btnUpload.IsEnabled = false;
imgSelectedImage.Source = null;
txtMessage.Visibility = Visibility.Visible;
}
catch
{
txtError.Visibility = Visibility.Visible;
}
}
}