Laravel Problem with UploadedFile getClientOriginalExtension() returns empty string
Laravel Problem with UploadedFile getClientOriginalExtension() returns empty string
Posted on
In Laravel when uploading files sometime getClientOriginalExtension() returns empty string.
Here is below explanation of problem and solution for it.
The getClientOriginalExtension() method returns the original file extension.
It is extracted from the initial file name that was uploaded. Then it shouldn’t be thought-about as a safe value.
So we should use guessExtension() method for resolution.
The guessExtension() method returns the extension based on the mime type.
This methodology uses the mime type as guessed by getMimeType() to guess the file extension.
Input::file('File')->guessExtension();
We think above solution will work for everyone who have this problem. Certainly for this stuff as well, we have GitHub source code link ready to grab it easily. We hope you discover this blog helpful and you’ve got any queries or feedback be at liberty to feature comment below this content.
Free SEO Checker |
Test your website for free with OnAirSEO.com
Logistic Infotech follows its predefined process to start the project approach. We will start the process from the research phase by doing proper research and analysis on the project requirements with client collaboration. After requirement analysis, we will move towards a designing phase of the project, as soon as the design will be finalized the development process of the project will be started meanwhile the daily check-ins and reporting from our side will be done regularly. After, that, We deliver your real app for mobile or website.