php 上传2m失败,用laravel做图片上传的时候,图片大于2m的时候就上传失败

赞同楼上的说法, 怀疑你报错信息贴的不正确, MethodNotAllowedHttpException用来判断请求的METHOD, 跟上传文件大小没有关系, laravel源码如下

MethodNotAllowedHttpException

// file vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php 221-252

/**

* Get a route (if necessary) that responds when other available methods are present.

*

* @param \Illuminate\Http\Request $request

* @param array $methods

* @return \Illuminate\Routing\Route

*

* @throws \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException

*/

protected function getRouteForMethods($request, array $methods)

{

if ($request->method() == 'OPTIONS') {

return (new Route('OPTIONS', $request->path(), function () use ($methods) {

return new Response('', 200, ['Allow' => implode(',', $methods)]);

}))->bind($request);

}

$this->methodNotAllowed($methods);

}

/**

* Throw a method not allowed HTTP exception.

*

* @param array $others

* @return void

*

* @throws \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException

*/

protected function methodNotAllowed(array $others)

{

throw new MethodNotAllowedHttpException($others);

}

// file vendor/symfony/http-kernel/Exception/MethodNotAllowedHttpException.php 12-31

/*

* This file is part of the Symfony package.

*

* (c) Fabien Potencier

*

* For the full copyright and license information, please view the LICENSE

* file that was distributed with this source code.

*/

namespace Symfony\Component\HttpKernel\Exception;

/**

* @author Kris Wallsmith

*/

class MethodNotAllowedHttpException extends HttpException

{

/**

* @param array $allow An array of allowed methods

* @param string $message The internal exception message

* @param \Exception $previous The previous exception

* @param int $code The internal exception code

*/

public function __construct(array $allow, $message = null, \Exception $previous = null, $code = 0)

{

$headers = array('Allow' => strtoupper(implode(', ', $allow)));

parent::__construct(405, $message, $previous, $headers, $code);

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值