laravel8(三)文件上传提示 “The file deos not exits ” ,但确实已经上传了文件

71 阅读1分钟

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

首先使用代码抛出异常

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

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

解决方案: 持续创作,加速成长!这是我参与「掘金日新计划 · 10 月更文挑战」的第11天,点击查看活动详情

我这里使用的是阿里云的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

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

欢迎访问个人博客 guanchao.site

欢迎访问我的小程序:打开微信->发现->小程序->搜索“时间里的”