2014-12-22 19 views
3

所以我一直堅持這一段時間,認爲它可以幫助其他人得到這種錯誤,也許你的天才球員可以幫助我理解這一點更好。用laravel 4.2靜默文件上傳,當文件太大時不工作

我一直在嘗試上傳文件通過用戶資源更新(PUT方法) 當文件太大我總是會得到「405方法不允許」的錯誤,如果文件是在正確的大小我wouldn'不會得到這種錯誤。 PHP工匠路線(有問題的線):

PUT user/{user} | user.update | [email protected]

即使試圖DD($ _ POST),或使用try和catch,我得到了同樣的錯誤。

'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' in C:\wamp\www\dsada\bootstrap\compiled.php:5693

一旦移動到簡單的帖子,一切完美的作品。

我的功能代碼:

if($_POST==null) 
     return Redirect::back()->with(['user' => $this->user, 'flash_bad' => 'too BIG']); 
    try{ 
     if(Input::file('picture')==null) 
      return Redirect::back()->with(['user' => $this->user, 'flash_bad' => 'must pick a picture']); 
     $picture = Image::make(Input::file('picture')); 
     $picture_size = $picture->filesize(); 
     $max_size_megabytes = 1; 
     if($picture_size > $max_size_megabytes*1024*1024) 
      return Redirect::back()->with(['user' => $this->user, 'flash_bad' => 'too big 2']); 

    }catch (Exception $e){ 
     return Redirect::back()->with(['user' => $this->user, 'flash_bad' => 'wrong file type']); 
    } 
+0

你可以在你的問題中添加你的觀點? –

回答

0

我認爲它可以和的upload_max_filesize的post_max_size要在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 

您將需要更新後重新啓動服務。