jaymc Posted December 16, 2006 Share Posted December 16, 2006 Im using headers to output a file as a SAVE AS link rather than to open it up in its default application when you click the direct linkIt works fine, but, I think its downloading them in ascii or something becayse when downloading an image it becomes corrupt. Its the same with a few other files that generally require binary downloadBelow is the code[code] header("Pragma: public"); header("Expires: 0"); // set expiration time header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header("Content-Disposition: attachment; filename=Jaydiocity_$filename[1]"); header("Content-Transfer-Encoding: binary");readfile("./uploads/".$file);[/code]Once again, the file downloads fine in full but is somehow corrupt. E.G a jpg file does not open up in the likes of windows FAX viewer, but will open up in paint shop pro for instance which obviously has some kind of error correction built inAny ideas? Quote Link to comment https://forums.phpfreaks.com/topic/30834-file-download/ Share on other sites More sharing options...
jaymc Posted December 16, 2006 Author Share Posted December 16, 2006 Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/30834-file-download/#findComment-142617 Share on other sites More sharing options...
jaymc Posted December 18, 2006 Author Share Posted December 18, 2006 Bump Quote Link to comment https://forums.phpfreaks.com/topic/30834-file-download/#findComment-144027 Share on other sites More sharing options...
Daniel0 Posted December 18, 2006 Share Posted December 18, 2006 When using complex variables (such as arrays) inside strings you need to enclose them in curly brackets ( {} ). Another header you might want to send is the Content-length header so the browser will know the size and thereby can estimate the time left to download the file.Where does $file come from?Edit: I really have to read the entire topic before replying. I think the thing I mentioned about the curly brackets could break it as if it has a wrong file extensions it's associations would be incorrect. Quote Link to comment https://forums.phpfreaks.com/topic/30834-file-download/#findComment-144029 Share on other sites More sharing options...
trq Posted December 18, 2006 Share Posted December 18, 2006 What is FAX viewer designed to open? Quote Link to comment https://forums.phpfreaks.com/topic/30834-file-download/#findComment-144031 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.