2

I am facing a very strange behavior when uploading 2 (or more) files of types GIF and PNG with one POST request per file. Requests are run in parallel.

When I upload one GIF and one PNG, the $_FILES array say the GIF file has the "image/png" type (while keeping the .gif extension).

The type of the PNG file is correct : "image/png".

Here is a dump of the $_FILES array :

[2022-03-24 08:33:03] local.DEBUG: array (  
    'file' =>  
    array (  
      'name' => 'news_avril_t1_mobile_02.gif',  
      'type' => 'image/png',  
      'tmp_name' => '/tmp/phpk18oS2',  
      'error' => 0,  
      'size' => 43124,  
    ),  
  )  
[2022-03-24 08:33:06] local.DEBUG: array (  
    'file' =>   
      array (  
        'name' => 'news_avril_t1_mobile_04.png',  
        'type' => 'image/png',  
        'tmp_name' => '/tmp/phpvYCxk5',  
        'error' => 0,  
        'size' => 8168,  
      ),  
    )  

There is no problem when uploading the GIF alone, or when uploading the GIF with a JPEG, or another GIF.
And of course, I did check that GIF is really a GIF (not a PNG file with the gif extension).
The problem only occurs when uploading a GIF with a PNG.

Any idea anyone?

Maxime Freschard
  • 1,066
  • 2
  • 15
  • 26
  • 1
    Does this answer your question? [PHP $\_FILES MIME type returning null](https://stackoverflow.com/questions/9653780/php-files-mime-type-returning-null) – Alex Shesterov Mar 24 '22 at 08:43
  • 2
    AFAIK this mime type is sent by the browser, so the problem isn't on "your end". Try with a different browser and consider filing a bug with your browser vendor. – tkausl Mar 24 '22 at 08:43
  • Browser sends the mime type, so it's a configuration issue on the CLIENT system. – Alex Shesterov Mar 24 '22 at 08:44
  • its not a bug, its [user supplied](https://stackoverflow.com/a/8775596). you should check on your browser console's network tab and verify whether the [multipart](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#multipartform-data) contains the correct mimetype (content type). there are many ways to circumvent this, but most involves opening the file with somekind tools - see the first link. – Bagus Tesa Mar 24 '22 at 08:47
  • Hi all, thanks for your feedback. Indeed the mime type sent by the browser is incorrect. Could this be also a bug from the upload library I use (dropzone.js) ? – Maxime Freschard Mar 24 '22 at 13:32

0 Answers0