2013-03-05 17:54
浏览 57


I am trying to get the uploadprogress module for lighttpd 1.5 to work, but i am running into a strange problem:

When i start the upload "/response" is getting called every second with the X-Progress-ID header set, but i am not getting any response. The GET call is just loading and loading but is getting no response. If call it manually (localhost/response?X-Progress-ID=someID) it appears to be right and the values for recieved and total are right and set. When i then cancel the upload progress (via the "X" Button in the Browser) /response keeps getting called, but now it will return with status 200, but, of course, with no right values set.

Here is my code:


 interval = null;

   function openProgressBar(uuid) {

        /* call the progress-updater every 1000ms */

        interval = window.setInterval(
             function () {

    function fetch(uuid) {
      req = new XMLHttpRequest();"GET", "/progress", 1);
      req.setRequestHeader("X-Progress-ID", uuid);
      req.onreadystatechange = function () {
      if (req.readyState == 4) {
        if (req.status == 200) {
            /* poor-man JSON parser */
            var upload = eval(req.responseText);

            document.getElementById('tp').innerHTML = upload.state;

            /* change the width if the inner progress-bar */
            if (upload.state == 'done' || upload.state == 'uploading') {
                bar = document.getElementById('progressbar');
                w = 400 * upload.received / upload.size;
       = w + 'px';
            /* we are done, stop the interval */
            if (upload.state == 'done') {

And my HTML:

 <form id="upload" enctype="multipart/form-data" 
     onsubmit="openProgressBar('{{tracking_id}}'); return true;">

     <input name="video" type="file" />
     <input type="submit" class="button orange medium" value="Upload" />


   <div id="progress">
   <div id="progressbar"></div>
   <div id="tp">(progress)</div>

EDIT: Forgot to mention...the {{tracking_id}} is getting generated in the php controller and printed with Twig.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • dsh77114 2013-03-06 11:45

    It seems to be a old bug with Chrome:

    Same issue..tested it with Firefox and it worked fine. Sadly this bug does exist for like 2-3 years now, so there is no big hope for a fix in the near future.

    Got it working with uploading the file via XMLHTTPRequest.

    解决 无用
    打赏 举报

相关推荐 更多相似问题