난 당신이 비동기 때문에이 파일을 업로드하려고하는 것 같아요 :
클라이언트 측 당신이 당신의 HTML 내에서 사용해야 할 파일을 선택하기 위해
:
<input type="file" id="file">
을
사용자는이 요소로 파일을 선택할 수 있습니다. 이제 자바 스크립트 부분 :
function upload() {
var formData = new FormData();
var target = //Upload-Server URL
formData.append("file", document.getElementById("file").files[0]);
var xhr = new XMLHttpRequest();
var eventSource = xhr.upload || xhr;
eventSource.addEventListener("progress", function(e){
var current = e.loaded || e.position ;
var total = e.total || e.totalSize;
var percant = parseInt((current/total)*100, 10);
// DO whatever you want with progress
});
xhr.open("POST", target, true);
xhr.send(formData);
xhr.onload = function() {
if (this.status === 200)
// SUCCESS
};
}
클라이언트 측
내가 파이썬 서버 측 코딩 경험이 없지만이 http://webpython.codepoint.net/cgi_file_upload 귀하의 경우에 유용 할 수 있습니다. 클라이언트 측에