Page 1 of 1

File download in CMS - Corrupting files

Posted: Thu Mar 12, 2009 11:26 pm
by tonholis
Hi all,

I did make my own module for download files from a specified folder, and when the user makes a download of the any file it is corrupted.

Example:  I put an Excel file on the my folder, it appears on my page, when I click to download, part of HTML appears on the excel file.

Here is the main code:

Code: Select all

header('Content-Length: ' . filesize($path));
header('Content-Type: ' . $mimetype);
header("Content-Disposition: attachment; filename=$name");

readfile($path);
exit();
any ideia?