laravel accept file
ringa_lee
ringa_lee 2017-05-17 09:55:47
0
1
661

In the laravel framework, an error is always reported when accepting files uploaded by inputs. The detailed code is as follows:

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.'];
         }
 
    }

The error is reported as follows:
1. Request usage error:
Non-static method Illuminate\Http\Request::file() should not be called statically, assuming $this from incompatible context
2. Wrong use of getClientOriginalExtension()
Call to a member function getClientOriginalExtension() on string

I hope God can give me some advice, urgent! ! !

ringa_lee
ringa_lee

ringa_lee

reply all(1)
仅有的幸福

Your Request class reference is wrong, it should be in supportfacades.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template