Real quick: find DownloadController.php and look at lines 78 – 81:

  1.        
  2. if ($contentDisposition = $helper->getContentDisposition()) {
  3.       $this->getResponse()
  4.            ->setHeader(‘Content-Disposition’, $contentDisposition . ‘; filename=’.$fileName);
  5. }

Change line 80 (line 3 in this excerpt) to:

  1. ->setHeader(‘Content-Disposition’, ‘attachment’ . ‘; filename=’.$fileName);

That should make it work. As far as I know, the .htaccess solutions to this problem don’t work in Magento, because Magento encrypts the filename and extension, and the path does not represent a real location.

Note: I usually don’t go around hacking the core files of a CMS, but sometimes I make an exception with deep extensions within Magento because it just takes so darn long to follow the variables through to their various sources in the code. Not that I don’t know how to do it …

By the way, if you’re not using Magento and just have regular paths to your files, put this in your .htaccess:

  1. AddType application/octet-stream .mov .mp3 .zip

This is one of the best .htaccess resources I’ve seen and it explains by example.

You can of course change the list of extension if you want. Hope this helps.

3 Comments

    The issue is now on Magento 1.4. Any hint?

    DonwoadController.php

    $this->getResponse()
    ->setHttpResponseCode(200)
    ->setHeader(‘Pragma’, ‘public’, true)
    ->setHeader(‘Cache-Control’, ‘must-revalidate, post-check=0, pre-check=0′, true)
    ->setHeader(‘Content-type’, $info['type'], true)
    ->setHeader(‘Content-Length’, $info['size'])
    ->setHeader(‘Content-Disposition’, ‘inline’ . ‘; filename=’.$info['title']);

    Thank You

  • OK, it was easier than before,

    In the backend;

    System | Configuration | Catalog | Downloadable Product Options |

    Under Use Content-Disposition change the ‘inline’ value to ‘attachment’

    Thanks

  • Nice! Glad they made a UI for this.

Leave a Reply