Debugging uploads in Laravel

Nav • August 27, 2020


Recently while debugging a file upload issues, i came accross a few helper methods that can save a lot of time.

Uploaded file returns a instant of Illuminate\Http\UploadedFile, which extends symfony's SymfonyUploadedFile


Returns whether the file was uploaded successfully.


Returns the upload error. If the upload was successful, the constant UPLOAD_ERR_OK is returned. Otherwise one of the other UPLOAD_ERR_XXX constants is returned.


This will return an error code. Here is the list of error codes:

Code Meaning
0 There is no error, the file uploaded with success
1 The uploaded file exceeds the upload_max_filesize directive in php.ini
2 The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form
3 The uploaded file was only partially uploaded
4 No file was uploaded
6 Missing a temporary folder
7 Failed to write file to disk
8 A PHP extension stopped the file upload

Returns the maximum size of an uploaded file as configured in php.ini. This is especially helpfull to check if your php.ini settings are being respected.


Returns an informative upload error message.