ionic照片上传到服务器后,服务器端接收的问题
采用ionic+angular 进行开发,通过vs013进行编辑,实现手机上的照片传到服务器,问下大家请问服务器端写什么函数进行接收呢,怎么实现,请大家帮忙。
客户端:
type = 'gallery';
$scope.kpic = [];
var fobj = [];
var imgList = [];
window.imagePicker.getPictures(
function (results) {
console.log(results);
for (var i = 0; i < results.length; i++) {
var file = results[i];
var options2 = new FileUploadOptions();
options2.fileKey = "file";
options2.fileName = results[i].substr(results[i].lastIndexOf('/') + 1);
options2.mimeType = "image/jpeg";
fobj[i] = new FileTransfer();
fobj[i].onprogress = function (progressEvent) {
//上传中
$ionicLoading.show({ template: '上传中,请等待...' })
};
fobj[i].upload(file, encodeURI(“”), function (re) {
console.log(JSON.stringify(re));
console.log(re.responseCode);
var status = JSON.parse(re.response).status;
if (status == 1) {
console.log("上传成功");
var img_url = JSON.parse(re.response).data;
console.log(img_url);
$scope.chat.ct = img_url;
$scope.chat.tag = "pic";
$scope.send();
$ionicLoading.hide();
console.log("tab:" + $scope.chat.tag)
} else { $ionicLoading.hide(); }
}, function (e) { console.log(JSON.stringify(e)); $ionicLoading.hide() }, options2);
}
}, function (error) { console.log('Error: ' + error); }, { maximumImagesCount: 10, width: 800 });
return true;
服务器端:我设想是否这样接受?
/// <returns></returns>
[HttpPost]
public ActionResult UploadifyFile(string folderId, string modelType,string userID, HttpPostedFileBase Filedata)
{
}