php:文件传输不上传视频到服务器

时间:2017-12-03 16:42:45

标签: php cordova

我正在使用cordova文件传输插件将视频上传到我的网络服务器。下面是前端的代码。

var uri = encodeURI("https://www.abc.xyz/app/upload_vid.php");

        fileURL = "file://"+filefromgallery;
        var options = new FileUploadOptions();
        options.fileKey="file";
        options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1);
        options.mimeType="video/mp4";
        options.chunkedMode = false;

           options.headers = {
               Connection: "close"
            };

        var ft = new FileTransfer();
        ft.onprogress = function(progressEvent) {
            if (progressEvent.lengthComputable) {
                loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total);
            } else {
                loadingStatus.increment();
            }
        };
        ft.upload(fileURL, uri, win, fail, options);
}

这是后端代码。

    $dirname = "./video";
$filename = 'test';
        if ($_FILES) {
            print_r($_FILES);
            move_uploaded_file($_FILES["name"]["tmp_name"],$dirname."/".$filename.'.mp4');
        }

我今天做了一些调试。 这是print_r($_FILES);

的输出
Response = Array
(
    [file] => Array
        (
            [name] => video-name-here.mp4
            [type] => video/mp4
            [tmp_name] => /tmp/phpJzw3UB
            [error] => 0
            [size] => 479000
        )

)

<b>Notice</b>:  Undefined index: name in <b>/home/u966130057/public_html/model_app/upload_vid.php</b> on line <b>18</b><br />

In Console debug i am getting below error for frontend.
Uncaught ReferenceError: loadingStatus is not defined
    at FileTransfer.ft.onprogress (index.js:214)
    at win (FileTransfer.js:159)
    at Object.callbackFromNative (cordova.js:293)
    at <anonymous>:1:283

0 个答案:

没有答案