douyi6168 2012-07-11 11:08
浏览 73
已采纳

Nginx上传进度模块

I have a pretty wide-spreaded question .... I don't understand how Upload Progress Module works , and it kind of doesn't work for me too , so ....

1) I have installed nginx with all the upload modules (nginx, nginx-extras) , and php-fpm

2)This is part of my nginx config for the project:

    location ~ \.php$ {
  include /etc/nginx/fastcgi_params;
  fastcgi_pass 127.0.0.1:9000;
  fastcgi_param SCRIPT_FILENAME /home/cha0s/learnphp$fastcgi_script_name;
  fastcgi_param PATH_INFO $fastcgi_script_name;

  track_uploads proxied 1m;
}

location ~ ^/files/(.*)$ {
        alias /home/cha0s/$1;
        internal;
}

location ^~ /progress {
        # report uploads tracked in the 'proxied' zone
        report_uploads proxied;
}

3)I followed the tutorial at the bottom of this page: http://wiki.nginx.org/HttpUploadProgressModule :

So i have a form and upload progress bar:

<form id="upload" enctype="multipart/form-data" action="index.html" method="post">
  <input name="file" type="file"/>
  <input type="submit" value="Upload"/>
</form>
<div id="uploading">
  <div id="progress" class="bar">
    <div id="progressbar"> </div>
    <div id="percents"></div>
  </div>
</div>

JS code that triggers the jquery script:

  <script type="text/javascript">
    $(document).ready(function(){
      $('form').uploadProgress({
        /* scripts locations for safari */
        jqueryPath: "/static/js/jquery.js",
        uploadProgressPath: "/static/js/jquery.uploadProgress.js",
        /* function called each time bar is updated */
        uploading: function(upload) {$('#percents').html(upload.percents+'%');},
        /* selector or element that will be updated */
        progressBar: "#progressbar",
        /* progress reports url */
        progressUrl: "/progress",
        /* how often will bar be updated */
        interval: 2000
      }
    });
  </script>

And that script : https://github.com/drogus/jquery-upload-progress/blob/master/jquery.uploadProgress.js

Questions and Problems:

1)First problem is that i always get returned ({ "state" : "starting" }); ...

2)Second question is : the reason i began trying to make this thing work , is because i wanted to write a php script , which would slice file into chunks and send them to the server , so i could upload huge files , and have a progress bar to monitor it. But i couldn't even find the smallest example or tutorial how to get it done with php and upload_progress_module or w/e.

And no , i don't want flash based uploaders.

So i guess , you already understood that i am a confused. So if you could explain how i can get this done, and help solve the problem with already existing configuration would be great

  • 写回答

2条回答 默认 最新

  • dongpiao1983 2012-07-11 12:42
    关注

    action="index.html" doesn't look like the request that goes to location ~ \.php$.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料