laravel8(三)文件上传提示 “The file deos

2021-06-23  本文已影响0人  camellias__

Laravel 文件上传提示 “The file "" deos not exits ” ,但确实已经上传了文件

首先使用代码抛出异常

if($file->isValid()){ throw new \Exception('Error on upload file: '.$file->getErrorMessage());}

我这里遇到的是上传大小限制,但是不抛出异常的时候,提示的是文件不存在,小白很容易误解!

解决方案:

我这里使用的是阿里云的centos服务器

1:找到你的php.ini文件

2:打开后,分别设置

upload_max_filesize = 50M
post_max_size = 50M

3:找到你的nginx配置文件nginx.conf

然后在http块中 设置 分块上传大小,添加或修改下面这行代码

client_max_body_size 50m;

4:重启nginx 跟 php

systemctl restart nginx  #重启nginx
systemctl restart php-fpm  #重启php-fpm

有好的建议,请在下方输入你的评论。

欢迎访问个人博客
https://guanchao.site

上一篇 下一篇

猜你喜欢

热点阅读