Tuesday, December 08, 2015

Firefox can't upload pdf files ? Here are some solutions


There is a problem with Firefox that was reported many times since 2007 :

When you want to upload a PDF file to a web site, let's say an invoice document for instance, some web sites will refuse it, arguing that it is not a PDF file.


The problem is usually caused by Firefox not sending the correct file type to the web site. This type is called a MIME type. Depending on how the web site is programmed, this will happen or not.

The correct MIME type for a pdf file is application/pdf.

Unfortunately, if there are several MIME types associated to pdf files in Firefox, it will use the last MIME type it finds in its configuration file when uploading such a file to a remote web site. I guess it is not only for pdf files, it is certainly the same for all kind of files, provided that there is a MIME type associated to them.

Furthermore, the setting Firefox uses to send the MIME type when uploading a file is related to the extension of the file. Then, a definition of the MIME type that specifies the extension is required if one wants to customize (or fix) the MIME type that FF sends when uploading a particular type of file.

In my case, Firefox was sending the MIME type application/force-download instead of the MIME type application/pdf.

To correct that, one has to make some changes in the configuration file that Firefox uses for setting its MIME types. This file is called mimeTypes.rdf.

It is in your Firefox profile folder.

The profile folder can be found as described here:
https://support.mozilla.org/en-US/kb/profiles-where-firefox-stores-user-data#w_how-do-i-find-my-profile
 
  1. Click the menu button , click help and select Troubleshooting Information. The Troubleshooting Information tab will open.
  2. Under the Application Basics section, click on [Show Folder] button A window with your profile files will open.

The "help" question mark is at the bottom of the menu window, and then, the [Show Folder] button is available, similar to this :





Now, you click on [Show Folder] button, a window with all the files in your profile folder will open up.

You have then to scroll down to the file mimeTypes.rdf


And then open it up with a text editor. I used Notepad++ for Windows, but any text editor (or XML editor) should work ok.

When mimeTypes.rdf is opened and ready for editing, search the word pdf in it (use the integrated search feature in your text editor).


Solution 1: Create correct MIME type definition at the end of mimeTypes.rdf file


You must make sure that last mention to files with pdf extensions type in the mimeTypes.rdf file is similar to the following:
  <RDF:Description RDF:about="urn:mimetype:handler:application/pdf"
                   NC:fileExtensions="pdf">
  </RDF:Description>

You can then just add the lines that refer to files with a pdf extension and state that the MIME type is application/pdf (the few lines similar to what is just above) at the end of the mimeTypes.rdf file.

Don't mess up with the headers and footers of the file, they must stay untouched.
The end of your mimeTypes.pdf file should then be similar to:
  <RDF:Description RDF:about="urn:mimetype:handler:application/pdf"
                   NC:fileExtensions="pdf">
  </RDF:Description>
</RDF:RDF>



Solution 2: Remove the incorrect MIME type definitions


If you see anything like the following:
  <RDF:Description RDF:about="urn:mimetype:application/force-download"
                   NC:fileExtensions="pdf"
                   NC:description=""
                   NC:value="application/force-download"
                   NC:editable="true">
    <NC:handlerProp RDF:resource="urn:mimetype:handler:application/force-download"/>
  </RDF:Description>

Delete all the lines between <RDF:Description and </RDF:Description> (included).
You may have to do this for all sections that embed the line NC:fileExtensions="pdf" (but the last one if you have also chosen solution 1).


For both solutions: save and reload


Now you will have to close Firefox.
But wait !
If you are reading this article with Firefox, save your mimeTypes.rdf file before closing Firefox.

Close Firefox, optionally, save again mimeTypes.rdf if it was modified by Firefox when it closed. Notepad++ will warn you if this is the case and you must not reload the file then, before saving it again.

Start Firefox again, and voilà, you should be able to upload pdf files to web site inside Firefox.




No comments: