2013-07-18 60 views
0

我试图做一个简单的文件上传。我以前做过很多次了,一切都很好。由于某种原因,这次我不断收到错误UPLOAD_ERR_INI_SIZE。即使我以前在同一台服务器上上传了更大的文件。这里是我的php.ini:Max_File_Uploads指令php.ini

display_errors = On 
short_open_tag = On 
memory_limit = 32M 
date.timezone = Europe/Paris 
upload_max_filesize = 10M 
post_max_size = 10M 

而我的HTML表单:

<form action="/settings/upload-image" method="POST" enctype="multipart/form-data"> 
    <input type="hidden" name="MAX_FILE_SIZE" value="<?=(1024*1024*1024);?>"> 
    <input name="files[]" id="attachfile" type="file" /> 
    <br /><br /> 
    <input type="submit" class="submit" value="Upload New Profile Image">  
</form> 

而且我的代码:

foreach($files as $file) 
       { $ext = strtolower(pathinfo($file[0], PATHINFO_EXTENSION)); 
        if(in_array($ext,$allowed_upload_ext)===TRUE) 
        {  
          if(!$file[3]) {  // If no error code 
           //$newFile = $me['id'].".$ext"; 
           $newFile = $file[0]; 
           resizeImage($file[2],PROFILE_IMAGES."/".$newFile,$ext,500); 
           genThumbFile($file[2],PROFILE_IMAGES."/thumb/".$newFile); 

           runSQL("UPDATE `users` SET `image`='{$file[0]}' WHERE `id`='{$me['id']}';"); 
           array_push($msgs,"Image uploaded successfully."); 
           $me = select("SELECT * FROM `users` WHERE `id`='{$me['id']}';",true); 
          } else { 
           array_push($msgs,"!".fileError($file[3])); 
          } 
        } else { 
         array_push($msgs,"!The file ".$file[0]." could not be uploaded as it is the wrong file type."); 
        } 
       } 

唯一不同的这一次是我调整大小和genorating大拇指与临时上传文件,而不是先复制文件。这可能是问题吗?我不这么认为,因为如果图像很小,它的效果就很好。但我尝试了2MB之类的东西,它会抛出一个合适的结果。

对此提出建议?

回答

0

感谢您的帮助家伙。 :P

我解决了这个问题 - 缺少一行在php.ini:

file_uploads = On

刚的人谁鳍片这一点。