We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34084 ☆ A M B ☆
    • 756 Posts
    I've created a new Content type with the following properties:
    MIME Type: application/zip
    File Extension: .zip
    Binary: Checked (true)

    Then in my resource the Settings have the Content Type selected as "Zip", for above, and the content Disposition as "Attachement" then Class Key as "Document".

    My snippet in the resource call is:
                    header('Content-Description: File Transfer');
                    header('Content-Type: application/octet-stream');
                    header('Content-Disposition: attachment; filename='.basename($file));
                    header('Content-Transfer-Encoding: binary');
                    header('Expires: 0');
                    header('Cache-Control: must-revalidate');
                    header('Pragma: public');
                    header('Content-Length: ' . filesize($file));
                    readfile("$file");
                    exit;


    I get a corrupt downloaded file every time, however if I go to the physical file path on the server I can open it directly. The zip file is being created on they fly, so I can not just make a direct link. Any thoughts?

    Cheers
      Evo Revo // Ubuntu, CentOS, Win // Apache 2x, Lighttp (Lighty)
      Visit CharlesMx.com for latest news and status updates.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      You can just make it a static resource, and it should download it fine.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 34084 ☆ A M B ☆
        • 756 Posts
        Yeah, tried changing the Class Key to Static Resource did not change the results.

          Evo Revo // Ubuntu, CentOS, Win // Apache 2x, Lighttp (Lighty)
          Visit CharlesMx.com for latest news and status updates.