2012-03-28 21 views
0

我在ZF應用此代碼上傳:不能上傳JPG比其他任何事情

public function uploadAction() { 
    $upload = new Zend_File_Transfer_Adapter_Http(); 
    $upload->setDestination("uploads"); 
    if (!$upload->isValid()) { 
     throw new Zend_Exception("Upload Error"); 
    } 
    try { 
     $upload->receive(); 
    } catch (Zend_File_Transfer_Exception $e) { 
     throw new Zend_Exception('Upload Error ' . $e->getMessage()); 
    } 


    $this->_helper->viewRenderer->setNoRender(); 
} 

和下面的HTML:

<form enctype="multipart/form-data" action="admin/upload" method="POST"> 
<input type="hidden" name="MAX_FILE_SIZE" value="100000" /> 
Choose a file to upload: <input name="Filedata" type="file" /><br /> 
<input type='hidden' name='MAX_FILE_SIZE' value='10000' /> 
<input type="submit" value="Upload File" /> 
</form> 

一切工作正常使用JPG文件...但我得到Zend的例外JPG和PNG和...等:

Fatal error: Uncaught exception 'Zend_Exception' with message 'Upload Error' in D:\xampp\htdocs\sc\application\controllers\AdminController.php on line 2539 (!) Zend_Exception: Upload Error in D:\xampp\htdocs\sc\application\controllers\AdminController.php on line 2539

我調試了異常和var轉儲驗證器消息... f ound:

array 


'fileUploadErrorFormSize' => string 'File 'Filedata' exceeds the defined form size' (length=45) 
+0

'File'Filedata'超出定義的表單大小'檢查你的php.ini的max_post_size,max_upload_filesize和max_file_uploads:http:// de.php.net/manual/en/ini.core.php#ini.post-max-size – dbrumann 2012-03-28 06:45:22

回答

1

您只需要一個<input type='hidden' name='MAX_FILE_SIZE' value='10000' />聲明。 10000是有點小,因爲這意味着你被限制在一個10Kb的文件...

+0

lol ...通過在uploadify腳本中添加上傳到AUTO來修復 – 2012-03-28 08:03:37

相關問題