1

On trying to download a pdf file my Firefox downloads a file without file ending and means it would be an application/octet-stream file:

enter image description here

Only after a manually add to the file the ending pdf i become able to open it with usual tools.

The questions are:

  • on which side is a problem? On my or on the administrator of the site, where i download the file?
  • In both cases: what is exactly wrong?

My guess was, the site administrator wanted to force users to download his pdf files, instead of open them in browser, with something like this setting:

AddType application/octet-stream .pdf

But where the file ending is remains the dark secret for me.

  • What do you mean by "manually adding the file ending"? Was .pdf not on the download link, but manually adding fixes the problem? – Stephen Ostermiller Apr 19 '17 at 19:51
  • @StephenOstermiller i mean, after the file without ending is saved on the hard disk, i rename it whilst add to the end of file name .pdf manually. After this the file becomes to be opened with reader software. Without adding of .pdf on trying to open the file, Windows means, the file is unknown and i should select a software to open such files. – Evgeniy Apr 20 '17 at 1:30
  • If you don't have the file extension, then the browser doesn't know what to do with the file as it has no idea it is a PDF or TXT or PHP or whatever. – Steve Apr 20 '17 at 3:50
  • @Steve thats correct. The question is: can i do something to get files healthy or only the site administrator, who manages files? – Evgeniy Apr 20 '17 at 8:00
  • Only the site admin unless you have access to the server files or see Stephen Ostermiller's answer below – Steve Apr 20 '17 at 8:13
3

To get the .pdf extension on the file after download, it needs an HTTP header like:

Content-Disposition: attachment; filename=some-file.pdf;

With this header it will be saved as some-file.pdf even if served from the URL /pdf-download.php

See on StackOverflow: How to Use Content-disposition for force a file to download to the hard drive?

  • Does it mean, i can't do anything to get files healthy? Does it need only an action from the site administrator, who manages files (and their headers)? – Evgeniy Apr 20 '17 at 7:58
  • Yes, it needs the webmaster involvement. Otherwise this question would be off-topic for this site. – Stephen Ostermiller Apr 20 '17 at 8:42
1

PDF download fails ...

By the sound of it, the PDF download isn't "failing", it's just not being saved with a .pdf file extension. This is probably only a "problem" on Windows, that requires the file extension in order to determine the file type. As I understand it, Mac users will still be able to open the file without issue.

The fact that the file is being saved without an extension implies the URL linking to the file is also without the appropriate file extension.

You can (as a user) improve this situation by configuring your browser to always prompt for file downloads (recommended, although rarely the default configuration) - you can then simply rename the file in the "Save As..." dialogue (which I would often do anyway, as downloaded files are rarely named how you would like them to be).

AddType application/octet-stream .pdf

It is arguably incorrect behaviour to force a file download by setting the mime-type to application/octet-stream. This is very outdated in my opinion. This is simply a mime-type that the browser is probably unable to open, so as a last resort offers it for download in the hope that you know what to do with it.

The "correct" way to force a download would be to still set the correct mime-type (ie. application/pdf in the case of PDF files) but to also set the Content-Disposition: attachment; ... HTTP response header (as @Stephen suggests). It is the attachment part that forces a download in all modern browsers and the Content-Disposition header also always the "website" to set a recommended file name when the URL could be set to something completely different (this is still editable if you have the browser "prompt" for file downloads).

  • This is my doubt too: maybe the problem is placed on my side and caused by Windows or browser. I tried in the meanwhile to open the file without to add .pdfmanually to the file name. Just doubleclicked on it - Windows said, the file would be unknown and forced me to select an application. After i selected an acrobat reader it opened the file errorfree and without a file ending. – Evgeniy Apr 20 '17 at 13:54
  • If the site owner simply linked to a URL that included the .pdf extension then you wouldn't have this problem. Although they have perhaps (naively) removed the extension to further force the file to be downloaded. – MrWhite Apr 20 '17 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.