With the file received, I instantiate an
UploadedFile object, whichhas the following methods available:
$uploadedFile->getClientOriginalExtension(); $uploadedFile->getClientMimeType(); $uploadedFile->guessClientExtension(); $uploadedFile->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