【问题标题】:PHP remote file upload progress barPHP远程文件上传进度条
【发布时间】:2018-07-11 19:44:52
【问题描述】:

我想通过 PHP 和进度条将文件从前端上传到远程服务器,我该怎么做? 是否有可能无需在前端和远程服务器上安装额外的软件?

在前端服务器上有 apache、PHP 在远程服务器上有 nginx、PHP-FPM

【问题讨论】:

标签: php linux file-upload


【解决方案1】:

you can view this question in details。无论如何,当您从查询中调用 ajax 请求时,哪里是一个名为 uploadProgress 的函数,您可以调用并跟踪服务器中文件上传的状态和百分比。这个函数接受四个参数event, position, total, percentComplete

例子

$.ajax({
    beforeSend: function() {
         // reset your progress bar here or do anything before making a call to endpoint
    },
    uploadProgress: function(event, position, total, percentComplete) {
        var percentVal = percentComplete + '%';
        $('#progressBar').width(percentVal);
    },
    complete: function(xhr) {
        alert(xhr.responseText);
    }
});

【讨论】:

    猜你喜欢
    • 2011-04-04
    • 2010-12-30
    • 2011-02-24
    • 1970-01-01
    • 1970-01-01
    • 2012-03-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多