I am having an issue, that I cannot seem to resolve!
Essentially, click on the downloads link and it all comes up with the open/save prompt. If you download any of the files, though, it says it's corrupted?
My max filesize in php.ini IS big enough to cope by far (test files range from 25kb to 655kb, and the max size is 2Mb!), and I am using firefox.
$array = mysql_fetch_array($query, MYSQL_ASSOC); $file = $_SERVER['DOCUMENT_ROOT'] . '/newsite/' . $array['download']; header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', FALSE); header('Pragma: no-cache'); header('Content-Description: File Transfer'); header('Content-Type: octet-stream'); header('Content-Type: application/force-download'); header('Content-Length: ' . filesize($file)); header('Content-Disposition: attachment; filename=' . basename($file)); header("Content-Transfer-Encoding: binary"); readfile($file);Now the document root isn't an issue, if i comment out the headers and just do
echo $file;then it shows the correct root path for the server to the file.
When you download, it does prompt with the right filename etc, and when downloaded - it's the right size too.
Error messages are (zip file being used, contents are 5 php files).
or if you double click instead of using "extract here", it will open the extract window and say:
The archive is either in unknown format, or damaged
, but shows the files and their sizes okay.
Unexpected end of archive
Anyone have any ideas as to what I am doing wrong/spot the bug that I am having?
Help would be much appreciated, downloads are integral to the site i have created, and everything else is working just fine Supposed to present either later today, or tomorrow - and would really like to remove the last few bugs.
If I use a pdf file to download instead, i get the following message:
"... could not open the file because it is either not supported file type or because the file has been damaged (for example it was sent as an email attachment and wasn't correctly decoded)"
That is when trying to open the acrobat pdf file with the reader