我想将图片从用户上传到服务器。响应告诉我上传成功但我的服务器中没有文件。
这是html
<button class="btn-group" ngf-select ng-model="userData.picFile" name="picFile" ngf-pattern="'image/*'"
ngf-accept="'image/*'" ngf-max-size="20MB" ngf-min-height="100"
ngf-resize="{width: 100, height: 100}">Select</button>
这是我的控制器
var profilePic = "profile_"+localStorageFactory.get('userdata').username;
/////////////////////////////upload//////////////////////////////////////////
$scope.submit = function() {
if ($scope.userData.picFile) {
$scope.upload($scope.userData.picFile);
}
};
// upload on file select or drop
$scope.upload = function (file) {
Upload.upload({
url: 'https://pettention.ga/pettention/img/profile',
data: {file: file,
name: profilePic}
}).then(function (resp) {
console.log('Success ' + resp.config.data.file.name + 'uploaded. Response: ' + resp.data);
}, function (resp) {
console.log('Error status: ' + resp.status);
}, function (evt) {
var progressPercentage = parseInt(100.0 * evt.loaded / evt.total);
console.log('progress: ' + progressPercentage + '% ' + evt.config.data.file.name);
});
};
提交表单时我有上传功能。这是响应消息
Success IMG_0067.JPGuploaded. Response: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
抱歉我的英文不好。谢谢。