php - laravel接受文件
ringa_lee
ringa_lee 2017-05-17 09:55:47
0
1
597

在laravel框架中接受inputs上传的文件一直报错,详细代码如下:

use Illuminate\Http\Request;
public function file(){
         $file = Request::file('photo');
         $allowed_extensions = ["png", "jpg", "gif"];
         if ($file->getClientOriginalExtension() && !in_array($file->getClientOriginalExtension(), $allowed_extensions)) {
             return ['error' => 'You may only upload png, jpg or gif.'];
         }
 
    }

报错如下:
1、Request使用错误:
Non-static method IlluminateHttpRequest::file() should not be called statically, assuming $this from incompatible context
2、getClientOriginalExtension()使用错误
Call to a member function getClientOriginalExtension() on string

希望大神指教,急急急!!!

ringa_lee
ringa_lee

ringa_lee

全部回复(1)
仅有的幸福

你的Request类引用错了,应该是supportfacades中的。

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!