File download in CMS - Corrupting files

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
tonholis
Forum Members
Forum Members
Posts: 21
Joined: Fri Nov 28, 2008 2:14 pm

File download in CMS - Corrupting files

Post 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?
Post Reply

Return to “Developers Discussion”