我想在用户提交表单时将图片移动到文件夹。我尝试了很多例子但没有成功。我想以这种方式提交带有图像的表单: -
mainApp.controller('productFormController', ['$scope', '$http', 'fileUpload', function($scope, $http, fileUpload) {
$scope.url = 'product-submit.php?&sub=1';
$scope.productsubmit = function(isValid) {
if (isValid) {
$http.post("product_image": $scope.product_image,"product_description": $scope.product_description}).
success(function(data, status) {
console.log(data);
// window.location.href = 'products';
})
}else{
$scope.errorMsg = "Form is not valid";
}
}
}]);
<form class="form-horizontal" name="useradd" enctype="multipart/form-data">
<input type = "file" ng-model = "product_image"/>
<textarea name="product_description" class="form-control"ng-model="product_description"></textarea>
<button class="md-btn md-btn-primary waves-effect waves-light" ng-click="productsubmit(useradd.$valid)"><i class="fa fa-check"></i> Save</button> | <a href="#">Or Cancel</a>
</form>
我想以这种方式添加我的表单,并且还想将图像存储到文件夹中。