所以我已经坚持了一段时间,认为它可能会帮助其他遇到这种错误的人,也许你们这些天才可以帮助我更好地理解这一点。
我一直在尝试通过用户资源更新(PUT 方法)上传文件 当文件太大时,我总是会得到“405 Method not Allowed”错误,如果文件大小正确,我就不会得到这种错误。 php artisan routes(有问题的行):
PUT 用户/{用户} |用户更新 | UserController@update
即使在尝试 dd($_POST) 或使用 try and catch 时,我也会遇到同样的错误。
'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' 在 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']);
}
最佳答案
我认为它可以是您的php.ini 中upload_max_filesize 和post_max_size 的值。像这样更改它,但使用您认为可以解决问题的尺寸:
; Maximum allowed size for uploaded files.
upload_max_filesize = 40M
; Must be greater than or equal to upload_max_filesize
post_max_size = 40M
更新后您需要重新启动服务。
关于php - 使用 laravel 4.2 进行静态文件上传,文件太大时无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27607428/