B
B
BonBon Slick2016-11-27 13:13:25
Laravel
BonBon Slick, 2016-11-27 13:13:25

Why getClientOriginalExtension() will return jpg and extension() = jpeg when real jpg format is Laravel 5.3?

I'm trying the available methods, what can be done with a file in Laravel 5.3 , I noticed that the functions that should return the file format will return a different format.

echo '<br>'.$extension = $request->avatar->extension();
 // + guessExtension() + guessClientExtension()

Return: jpeg
echo '<br>'.$extension = $request->avatar->getClientOriginalExtension();

Verent: jpg
The actual file format is jpg .

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrzej Wielski, 2016-11-27
@BonBonSlick

The extension function returns the actual file extension given its mime type headers.
getClientOriginalExtension returns the file extension given by the user in the file name.
More specifically, you can download a .mp3 file with a .jpg extension and your system will miss it if it checks with getClientOriginalExtension

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question