I have Drupal website and my users can no longer download files. (docx, xlsx, etc). In firefox only, when the user clicks a link to download a file the page displays garbage code.

I read elsewhere the solution is to add the following, but it didn't work. Instead, the user is prompted with a dummy download for the application type each time the page reloads.

drupal_set_header('Content-type: application/octet-stream; charset=utf-8');

I have a simple module which has a page that spits out the links to the files. In this module I added the above to the hook_init() function.

Screenshot of the garbage code

I've never encountered this problem before, and I'm not sure why it started. Any help would of course be greatly appreciated. If I find a solution before someone replies with the answer I'll post it here for future reference.

  • 2
    Have you made any other changes to the system recently? This looks like the browser is confused about the content type. However, this is not normally handled by Drupal, but by the web server (e.g. Apache). If the web server is miscofigured, this may happen. (When it happened to me, Firefox was fine but MSIE was confused.) – Free Radical Jan 8 '13 at 7:32
  • No changes to the server have been. We've been trying to troubleshoot this, but we've had to move onto other tasks. So as a patch we just added a note for FF users, instructing them to right-click and select save. The issue itself remains unresolved and has taken a back seat for now. Thanks for trying to help. – SFox Jan 16 '13 at 1:09

Your Answer

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

Browse other questions tagged or ask your own question.