I'm trying to implement the ng-file-upload solution to my app.
So far I managed to upload and get a successfull callback, but when I check the upload folder through the FTP, it's still empty.
Here's my button:
<div class="col-xs-4 last" ngf-select="upload($file)">
<img class="img-responsive" src="/images/add.png" />
</div>
My JS:
$scope.upload = function (file) {
Upload.upload({
url: 'upload.php',
data: {
file: file,
'targetPath' : '/uploads/'
}
}).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);
});
};
My PHP code:
$filename = $_FILES['file']['name'];
$meta = $_POST;
$destination = $meta['targetPath'] . $filename;
move_uploaded_file( $_FILES['file']['tmp_name'] , $destination );
And the response I get:
progress: 47% 13428596_10153653711491485_8982166664082945936_n.jpg
progress: 71% 13428596_10153653711491485_8982166664082945936_n.jpg
progress: 94% 13428596_10153653711491485_8982166664082945936_n.jpg
progress: 100% 13428596_10153653711491485_8982166664082945936_n.jpg
angular.js:11881 XHR finished loading: POST "http://cccctanger.com/miquelimarc/upload.php".
Success 13428596_10153653711491485_8982166664082945936_n.jpg uploaded.
Response: $filename = $_FILES['file']['name'];
$meta = $_POST;
$destination = $meta['targetPath'] . $filename;
move_uploaded_file( $_FILES['file']['tmp_name'] , $destination );
It seems everything is fine, but no uploaded file to be found.
What am I missing?