With the file received, I instanciate an
UploadedFile object, so from which I can use the methods :
$newFile->getClientOriginalExtension(); $newFile->getClientMimeType(); $newFile->guessClientExtension(); $newFile->guessExtension();
I would expect those getters to return consistent results but it is not really what happens.
Return results for an uploaded file with named
'image-ile.jpg' are :
getClientOriginalExtension : '', getClientMimeType : application/octet-stream, guessClientExtension : bin, guessExtension : jpeg,
Content-Type : multipart/form-data :
Content-Disposition: form-data; name="image-ile.jpg"; filename="image-ile.jpg"
My question is :
In my case, the
guessClientExtension doesn’t return the relevant file extension while the
guessExtension does. So in which cases should I use one getter instead of the other one ?
Source: Symfony Questions