[wp-trac] [WordPress Trac] #39550: Some Non-image files fail to upload after 4.7.1

WordPress Trac noreply at wordpress.org
Fri Jan 13 07:00:54 UTC 2017


#39550: Some Non-image files fail to upload after 4.7.1
---------------------------+------------------------
 Reporter:  greatislander  |       Owner:  joemcgill
     Type:  defect (bug)   |      Status:  assigned
 Priority:  normal         |   Milestone:  4.7.2
Component:  Upload         |     Version:  trunk
 Severity:  normal         |  Resolution:
 Keywords:  needs-patch    |     Focuses:
---------------------------+------------------------

Comment (by mensmaximus):

 Replying to [comment:8 greatislander]:
 > I can confirm that in my testing of two `.docx` files, one of them
 returns `application/vnd.openxmlformats-
 officedocument.wordprocessingml.document` and uploads to WordPress as
 expected, while the other returns `application/octet-stream` and fails to
 upload.

 I cant see any malfunction in WP 4.7.1. The file you provided has the mime
 type 'application/octet-stream'. Function get_allowed_mime_types() returns
 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
 as the expected mime type for Word documents that carry .docx as
 extension. Both mime types don't match therefore the upload is denied.

 I opend the file in Word and saved it as a docx with different name. The
 new file could be uploaded without problem and shows the mime type
 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'.

 This behavior is expected in WP 4.7.1. You can check it e.g. by creating a
 CSV from an Excel file and rename it to .txt. Trying to upload that file
 will fail because the real mime type 'text/csv' won't match the expected
 mime type 'text/plain' as indicated by the extension.

 Imho the real issue is having files not telling the truth about their real
 nature. Users need to be educated to not mess around with extensions and
 developers need to be educated to use the correct mime types while
 creating files programmaticaly.

 Those servers throwing the finfo_file error message probably run on PHP
 prior to 5.3.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39550#comment:27>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list