在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
希望大神指教,急急! ! !