When to use UploadedFile guessClientExtension() vs guessExtension()?

  file-upload, php, symfony, symfony4

Uploading a file from a ReactJS/Javascript front end App to a Symfony 4 Backend, I try to get its file extension.

With the file received, I instantiate an UploadedFile object, whichhas the following methods available:


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'

Image file is sent using javascript FormData, with Content-Type: multipart/form-data :

Content-Disposition: form-data; name="image-ile.jpg"; filename="image-ile.jpg"
Content-Type: image/jpeg

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