2011-09-23 3 views
0

작은 파일은 동시에 5 개의 메가 바이트 파일을 업로드하더라도 원활하게 진행되지만 (한 번에 5 개만 처리하고 나머지는 대기시킵니다) 150MB 파일로 인해 브라우저가 중지됩니다 시작하는 동안 몇 초.큰 파일 업로드로 인해 브라우저가 중단됩니다.

function start(file) { 
    var xhr = new XMLHttpRequest(); 
    ++count; 

    var container = document.createElement("tr"); 

    var line = document.createElement("td"); 
    container.appendChild(line); 
    line.textContent = count + "."; 

    var filename = document.createElement("td"); 
    container.appendChild(filename); 
    filename.textContent = file.fileName; 
    filename.className = "filename"; 

    initXHREventTarget(xhr.upload, container); 

    var tbody = document.getElementById('tbody'); 
    tbody.appendChild(container); 
    tbody.style.display = ""; 

    var boundary = "xxxxxxxxx"; 

    xhr.open("POST", "uploader.php"); 

    xhr.setRequestHeader("Content-Type", "multipart/form-data, boundary="+boundary); // simulate a file MIME POST request. 
    xhr.setRequestHeader("Content-Length", file.size); 

    xhr.onreadystatechange = function() { 
     if (xhr.readyState == 4) { 
      if ((xhr.status >= 200 && xhr.status <= 200) || xhr.status == 304) { 
       if (xhr.responseText != "") { 
        alert(xhr.responseText); // display response. 
       } 
      } 
     } 
    } 

    var body = "--" + boundary + "\r\n"; 
    body += "Content-Disposition: form-data; name='upload'; filename='" + file.fileName + "'\r\n"; 
    body += "Content-Type: application/octet-stream\r\n\r\n"; 
    body += $.base64Encode(file.getAsBinary()) + "\r\n"; 
    body += "--" + boundary + "--"; 
    xhr.sendAsBinary(body); 

    } 
+0

엄청난 양의 데이터에 비추어 예상되는 동작과 비슷하게 들리지만 그렇지 않습니까? 이게 정말 문제 야? –

+0

큰 파일을 검색하고 게시하는 동안 브라우저가 멈추는 유일한 불만 사항이 있습니까? –

답변

2

그것은 파일의 내용에 후루룩 소리 내며 먹기 시간의 적지 않은 시간이 걸릴 것 IS, 64 기수를 인코딩 한 다음 문자열 연결을한다. 다른 말로하면 : 예상대로 행동하라.

+0

http://www.mediafire.com은 전혀 걸리지 않아도된다는 것을 보여줍니다. 같은 큰 파일을 브라우저에 걸면 브라우저가 멈추지 않고 계속 탭을 전환하고 파일 시작을 취소 할 수도 있습니다. 그래서 그들은 어떻게 다른가요? (참고 : 당신은 mediafire의 끌어서 놓기 기능을 얻고 내가 의미하는 것을보기 위해 firefox를 사용해야합니다) – natli

관련 문제