Fix – call to a member function getclientoriginalextension() on null
Posted on: February 10, 2021 by Deven
In this short article, i will share how to fix call to a member function getclientoriginalextension() on null error.
If you this error while uploading an imagecall to a member function getclientoriginalextension() on null
This means that no file input has been seen for that file. So, check that you input something in each file input.
Consider the example below:
$file = Input::file('name');
if ($file !== null) {
echo $file->getClientOriginalExtension();
}
Alternatively, you can use guessExtension() method for resolution. The guessExtension() method returns the extension based on the mime type.
Input::file('File')->guessExtension();
This methodology uses the mime type as guessed by getMimeType() to guess the file extension.
Share on social media
//