【发布时间】:2016-10-01 07:34:57
【问题描述】:
在我的Phonegap应用程序ios图片上传有一段时间不工作,不知道上传的确切原因, 在这里,我将图像作为表单数据上传, 前代码 - 要从照片中获取图片,
<input id="uploadImage" type="file" name="attachment" onchange="angular.element(this).scope().uploadFile(this.files)"/>
<button type="submit" class="ui-btn ui-btn-b" ng-click="post()"> Upload file</button>
JS 编码- //调用上传文件方法
$scope.uploadFile = function(files)
{
var fd = new FormData();
//Take the first selected file
fd.append("attachment", files[0]);
$localStorage.fd = fd;
};
$scope.post=function()
{
var fd=$localStorage.fd;
$http.post(httpurl, fd,
{
headers: {'Content-Type': undefined },
transformRequest: angular.identity
})
.success(function (res) {
alert("Image upload successfully");
})
.error(function(res){
alert("Image not uploaded");
})
现在的问题是,图像有时会上传,但不知道实际问题。我试图发布相同的图片上传,但它反映了同样的问题。 请分享您的反馈以解决我的问题。 提前致谢。
【问题讨论】:
标签: javascript ios angularjs cordova