Please note this is not a straightforward HTML->PHP file uploading issue. This is a part of a much bigger AngularJS app so the file has to be uploaded via AngularJS interface. When AngularJS script sends an image file to Php the file seems empty. In PHP sizeof($_FILES) returns 0. Any ideas? Thanks!
HTML code:
<div ng-app="myApp" ng-controller="myCtrl">
<form name="myForm">
<div>
<input type="file" ngf-select="onFileSelect(file)" name="file">
<span ng-show="fileMsg">{{fileMsg}}</span>
</div>
</form>
</div>
AngularJS code:
var app = angular.module('myApp', ['ngFileUpload']);
app.controller('myCtrl', function($scope, $http) {
$scope.fileMsg = "Checkpoint 1";
$scope.onFileSelect = function(file) {
var fd = new FormData();
fd.append('file', file);
$http.post("save_img.php", fd, {
transformRequest: angular.identity,
headers: {'Content-Type': undefined}
})
.then(function(response){
$scope.fileMsg = response.data;
});
}
});
PHP code:
echo $_FILES." size: ".sizeof($_FILES);