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();