Processing the uploaded file laravel
1, access uploaded files
File request- = $ $> File ( 'File');
2, retrieves the filename uploaded file (with the suffix, such as abc.png)
filename = File- $ $> getClientOriginalName ();
. 3, obtaining the uploaded file suffix (e.g. abc.png, is acquired png)
FileExtension = $ File- $> getClientOriginalExtension ();
4, get the size of uploaded files
File- filesize = $ $> getClientSize ();
. 5, obtaining cache file name (with the suffix, as php8933.tmp) in the tmp directory
filaname = $ File- $> getFilename ();
6, get uploaded files in the cache under the tmp folder absolute path
The realpath File- = $ $> the getRealPath ();
. 7, in the cache directory tmp file to a location after the return path of the file is moved
path = File- $ $> Move (path, newname);
Move () method takes two parameters, the first parameter is the path which the file to the folder, the second parameter is uploaded to the file rename file name
8, detection of the uploaded file is legitimate, the return value is true or false
$file->isValid()