내가 작업 lighttpd를 1.5에 대한 uploadprogress 모듈을 얻기 위해 노력하고 있어요,하지만 난 이상한 문제로 실행하고 응답이 : 내가 업로드 "/ 응답"을 시작하면업로드 진행
이 매 초마다 호출지고 X-Progress-ID 헤더가 설정되어 있지만 응답이 없습니다. GET 호출은로드 및로드 중일뿐 응답이 없습니다. 수동으로 호출하는 경우 (localhost/response? X-Progress-ID = someID) 올바른 것으로 나타나고 수신 및 전체 값이 올바로 설정됩니다. 그런 다음 업로드 진행률을 취소하면 (브라우저의 "X"단추를 통해)/응답이 계속 호출되지만 이제는 상태 200으로 반환되지만 물론 올바른 값이 설정되지 않은 상태로 반환됩니다.
자바 스크립트 : 여기
내 코드입니다interval = null;
function openProgressBar(uuid) {
/* call the progress-updater every 1000ms */
interval = window.setInterval(
function() {
fetch(uuid);
},
1000
);
}
function fetch(uuid) {
req = new XMLHttpRequest();
req.open("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;
bar.style.width = w + 'px';
}
/* we are done, stop the interval */
if (upload.state == 'done') {
window.clearTimeout(interval);
}
}
}
}
req.send(null);
}
그리고 내 HTML :
<form id="upload" enctype="multipart/form-data"
action="index.php?X-Progress-ID={{tracking_id}}"
method="post"
onsubmit="openProgressBar('{{tracking_id}}'); return true;">
<input name="video" type="file" />
<input type="submit" class="button orange medium" value="Upload" />
</form>
<div>
<div id="progress">
<div id="progressbar"></div>
</div>
<div id="tp">(progress)</div>
</div>
편집 : 잊어 버렸 언급 할 ... {{TRACKING_ID} }는 PHP 컨트롤러에서 생성되고 Twig로 인쇄됩니다.