Both methods returns the extention of the uploaded file, so why they both existe ? Can't find any diffrence between them.
Both methods returns the extention of the uploaded file, so why they both existe ? Can't find any diffrence between them.
These methods are available on every \Illuminate\Http\UploadedFile.
getClientOriginalExtension() returns the extension extracted from the original file name. If you send image.png, it'll be png
extension() returns the extension extracted from the file itself (using the mime type).
For instance, if you have a image.pdf file, you rename it image.png and then you upload it to your app:
getClientOriginalExtension() will return pngextension() will return pdf (or null if the mime type cannot be read)getClientOriginalExtension gets CLIENT extension, not the real mime-type extension, to get that use extension it is more secure