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

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

首先使用代码抛出异常

if($file->isValid()){ throw new \Exception('Error on upload file: '.$file->getErrorMessage());}
我这里遇到的是上传大小限制,可是不抛出异常的时候,提示的是文件不存在,小白很容易误解!php

解决方案:

以 ubuntu 为例 nginx

1 打开终端,输入下列命令行打开配置文件,若是使用的是cli,则使用/etc/php/7.2/cli/php.iniubuntu

sudo vim /etc/php/7.2/fpm/php.ini
复制代码

2 打开后,分别设置vim

upload_max_filesize = 50M
post_max_size = 50M
复制代码

3 配置nginx ,终端输入下列命令行打开配置文件php7

sudo vim /etc/nginx/nginx.conf 
复制代码

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

client_max_body_size 50m;
复制代码

4 重启nginx 跟 phpspa

sudo /etc/init.d/nginx restart
sudo /etc/init.d/php7.2-fpm restart
复制代码

命令行

相关文章
相关标签/搜索