在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 Illuminate\Http\Request::file() should not be called statically, assuming $this from incompatible context
2、getClientOriginalExtension()使用错误Call to a member function getClientOriginalExtension() on string
希望大神指教,急急急!!!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
你的Request类引用错了,应该是supportfacades中的。