首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PHP远程文件上载进度条

问PHP远程文件上载进度条
EN

Stack Overflow用户
提问于 2018-07-11 07:42:31
回答 1查看 392关注 0票数 0

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

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

EN

回答 1

Stack Overflow用户

发布于 2018-07-11 19:44:52

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

示例

代码语言:javascript
复制
$.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);
    }
});
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51275318

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档