2013-04-11 66 views
0

我上傳的文件與jQuery的Ajax阿賈克斯不張貼大文件

$("#transfer").live("click", function() 
{ 
    var data = new FormData(); 

    data.append("your_email", $("#your_email").val()); 
    data.append("your_message", $("#your_message").val()); 

    $.each($(".friends_email_item"), function(a,b) 
    { 
     var email = $(b).text(); 

     data.append("emails[]", email); 
    }); 

    for(i = 0; i < files.length; i++) 
     data.append("files[]", files[i]); 

    $.ajax({ 
     url: "upload.php", 
     type: "POST", 

     success: function(a) 
     { 
      console.log(a); 
     }, 

     data: data, 

     contentType: false, 
     processData: false 
    }); 
}); 

當我選擇一個小的文件,如文本文件或截圖。我得到了發佈的數據和發佈的文件的轉儲。

array 
    'your_email' => string '[email protected]' (length=14) 
    'your_message' => string 'test' (length=7) 

array 
    'files' => 
    array 
     'name' => 
     array 
      0 => string '1.png' (length=5) 
     'type' => 
     array 
      0 => string 'image/png' (length=9) 
     'tmp_name' => 
     array 
      0 => string 'C:\wamp\tmp\phpBD32.tmp' (length=23) 
     'error' => 
     array 
      0 => int 0 
     'size' => 
     array 
      0 => int 117994 

當我上傳50MB zip或一個500MB的視頻,我得到一個空數組回

array 
    empty 

array 
    empty 

爲什麼沒有張貼任何數據時,它是一個大的文件?這會影響上傳大小限制

+1

這很可能是一個服務器配置或php配置問題。 – 2013-04-11 20:09:40

+1

事實上,也許服務器的超時時間太短。 – Virus721 2013-04-11 20:11:11

+0

即使配置已修復,大型文件的失敗率也會更高。如果你看看其他網站做這種事情,他們通常使用這樣的分塊框架:http://www.plupload.com/ – AaronLS 2013-04-11 20:12:27

回答

2

檢查服務器配置: 使用phpinfo()看到值

  • upload_max_filesize,這臺對上傳的文件
  • post_max_size大小,這限制了總的上限發佈數據的大小,包括文件數據
  • max_input_time,它限制腳本允許處理輸入數據的時間長度,包括髮布的值

upload_max_filesize是對每個單獨文件的限制;但是,max_post_size是整個請求的上限,其中包含所有上傳的文件。

+0

謝謝,正是我所需要的 – John 2013-04-11 20:24:11