2010-11-23 95 views
19

我有一個簡單的上傳表單更大:

enctype="multipart/form-data"/> 

input type="hidden" name="MAX_FILE_SIZE" value="5900000" /> 

並進行如下設置,是在php.ini中應用(通過phpini()進行檢查):

upload_max_filesize = 7MB 
memory_limit = 64M 
post_max_size = 8MB 

我嘗試上傳一個小文件 - 500k,它通過GH

我嘗試上傳的文件是5MB(超過兩upload_max_filesizepost_max_size設置更小),它失敗,錯誤代碼1:這說的是:

UPLOAD_ERR_INI_SIZE 值:1;上傳的文件超出了php.ini中的upload_max_filesize指令。

任何人都有線索是怎麼回事?

回答

40

我認爲這是因爲一個錯字。取而代之的

upload_max_filesize = 7MB 

應改爲

upload_max_filesize = 7M 

使用phpinfo()再次檢查實際上得到應用什麼樣的價值。

+3

你是對的,解決了這個問題。我沒有意識到的技巧是phpinfo()確實顯示了7MB的值,但它並不認爲它適合。現在都很好,luv ya – mgpepe 2010-11-23 11:43:35

+0

+1好點:) – karim79 2010-11-23 11:44:24

6

您還可以設置「的php.ini」

3
upload_max_filesize = 7M 
here the value is in 7M or 10M but not MB. 
use `phpinfo()` again to check what value actually gets applied. 

運行這個程序也一度可以更容易理解的問題是什麼post_max_size如果文件大小的擴展意味着簡單地把它打印出來把爲超過php.ini中的upload_max_filesize指令

 <?php 
     $error_types = array(
     1=>'The uploaded file exceeds the upload_max_filesize directive in php.ini.', 
     'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.', 
     'The uploaded file was only partially uploaded.', 
     'No file was uploaded.', 
     6=>'Missing a temporary folder.', 
     'Failed to write file to disk.', 
     'A PHP extension stopped the file upload.' 
     ); 

     // Outside a loop... 
     if($_FILES['userfile']['error']==0) { // here userfile is the name i.e(<input type="file" name="*userfile*" size="30" id="userfile"> 
     echo"no error "; 
     } else { 
      $error_message = $error_types[$_FILES['userfile']['error']]; 
      echo $error_message; 
     } 
by this we can easily identifies the poblem or we can use switch case also to print 
1

這是一個很大的錯誤,我已經做了:

如果你想上傳真正的大文件,你必須設置KeepAliveTimeout高於5秒的默認值。

例如:

KeepAliveTimeout 300 

你可以找到/etc/apache2/apache2.conf

0

轉到這個屬性W¯¯HM->Service Configuration->PHP Configuration Editor和更新的upload_max_filesize值。