php - 使用 laravel 4.2 进行静态文件上传,文件太大时无法正常工作

标签 php rest laravel

所以我已经坚持了一段时间,认为它可能会帮助其他遇到这种错误的人,也许你们这些天才可以帮助我更好地理解这一点。

我一直在尝试通过用户资源更新(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/

相关文章:

java - 好的做法? REST 中的一两个对象模型用于创建和获取资源

c# - 我应该有两个不同的模型类来读取和更新 Web API 中的对象吗?

laravel - docker 组成 : how to use minio in- and outside of the docker network

php - mysql数据检索只返回一行

php - 在 mySQL 中将日期值转换为会计/纳税年度

php - 如何从 PHP 中的图像变量加载 blob

Laravel Eloquent get() 按主键 id 索引

php - 切割 HTML 标签并重新包装 HTML 标签 Part/1

JavaScript REST 客户端和 session 管理

laravel - 下拉列表的基表