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
複製代碼

命令行

相關文章
相關標籤/搜索