2014-09-25 22 views
0

我有jquery文件上傳最小安裝。我的目的是能夠上傳大容量10GB的大文件。但現在我只能上傳最大25MB。上傳完成後,代碼會返回文件的名稱。當我嘗試在本地主機上傳6GB時,進度條擊中100%,但返回一個奇怪的數字,如「1411637366-99」而不是文件名,上傳文件夾中沒有文件。我沒有弄明白。jquery文件上傳最小安裝大文件

另外我試着上傳一個55MB的文件。當我這樣做時,一切看起來都正常,正確返回文件名,但上傳文件夾中沒有文件了。

enter image description here

<!DOCTYPE HTML> 
<html> 
<head> 
<meta charset="utf-8"> 
<title>jQuery File Upload Example</title> 
</head> 
<body> 
<input id="fileupload" type="file" name="files[]" data-url="server/php/" multiple> 
<div id="progress"> 
    <div class="bar" style="width: 0%; height: 18px; background: green;"></div> 
</div> 
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
<script src="js/vendor/jquery.ui.widget.js"></script> 
<script src="js/jquery.iframe-transport.js"></script> 
<script src="js/jquery.fileupload.js"></script> 
<script> 
$(function() { 
$('#fileupload').fileupload({ 
    dataType: 'json', 
    done: function (e, data) { 
     $.each(data.result.files, function (index, file) { 
      $('<p/>').text(file.name).appendTo(document.body); 
     }); 
    }, 
    progressall: function (e, data) { 
     var progress = parseInt(data.loaded/data.total * 100, 10); 
     $('#progress .bar').css(
      'width', 
      progress + '%' 
     ); 
    } 
}); 
}); 
</script> 
</body> 
</html> 

回答

1

我覺得你的問題是在PHP,而不是在jQuery的。

在PHP ini文件

你有:

; Maximum allowed size for uploaded files. 
upload_max_filesize = 40M 

; Must be greater than or equal to upload_max_filesize 
post_max_size = 40M 

您應將其更改爲你的願望。

,或者如果你沒有訪問您的ini文件,你可以做到這一點對單個文件[你的情況在UploadHandler.pho]與

<?php 
    ini_set('upload_max_filesize', '10M'); 
?> 

或者,你寫道:你可以創建一個.htaccess使用以下文件:

php_value upload_max_filesize 10000M and php_value post_max_size 10000M **and** php_value memory_limit 128M 
+0

我無法訪問php.ini。我可以在UploadHandler.php中做到嗎? – kastelli 2014-09-25 09:50:59

+0

你可以用ini_set('upload_max_filesize','10M');在你的文件上。 – 2014-09-25 09:53:59

+1

Yeap,你是對的,但ini_set不適合我,我不知道爲什麼。我只是用UploadHandler.php在同一個文件夾中創建一個.htaccess文件,並且我把這個行放在了'php_value upload_max_filesize 10000M'和'php_value post_max_size 10000M'和'php_value memory_limit 128M'中,然後問題解決了!也許你可以添加這個.htaccess到你的正確答案。謝謝! – kastelli 2014-09-25 10:05:08

相關問題