如何将图像从移动设备上传到我的外部数据库?
这是我当前的 WCF 服务:
界面:
[WebInvoke(UriTemplate = "/Upload", Method = "POST", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped), CorsEnabled]
string UploadProfileImage(string image);
上课方法:
public string UploadProfileImage(string image)
{
// Upload code needs to go here.
}
我可以很好地使用 ajax 发布,我只是迷失了如何使用图像来做到这一点。
这是我如何发布帖子的 jQuery 示例。
// This is the success function that gets called after selecting an image from my device
function uploadSuccess(imageURI) {
uploadImage(imageURI);
}
function uploadImage(imageURI)
{
var data = '{"image":"' + imageURI + '"}'
$.ajax({
url: "http://192.168.101.55:8848/api/Upload",
type: "POST",
contentType: "application/json",
data: data,
success: function (result) {
},
error: function (jqXHR, textStatus, errorThrown) {
}
});
}