dtrn74832 2016-07-11 23:18
浏览 25

在AngularJS中显然成功上传后文件中缺少文件

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?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
    • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
    • ¥15 MATLAB中streamslice问题
    • ¥15 如何在炒股软件中,爬到我想看的日k线
    • ¥15 seatunnel 怎么配置Elasticsearch
    • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
    • ¥15 (标签-MATLAB|关键词-多址)
    • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
    • ¥500 52810做蓝牙接受端
    • ¥15 基于PLC的三轴机械手程序