spooke2k Posted June 10, 2007 Share Posted June 10, 2007 if( $_POST['Download_button']=='Download' ) { $part1 = 'http://testetc/pressservice//'; $part2 = $_POST['group1']; $part3 = '.jpg'; $file = $part1 . $part2 . $part3; echo $file; header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header( "Content-Disposition: attachment; filename=".basename($file)); header( "Content-Description: File Transfer"); @readfile($file); can anyone tell me why the header code bits work if there at the top of the php script but dont if they are position as they are now or how i can fix this thanks code works fine on its own if its at top with preset variables like file = "path of what file is" spooke2k Quote Link to comment https://forums.phpfreaks.com/topic/54970-solved-headers/ Share on other sites More sharing options...
tekrscom Posted June 10, 2007 Share Posted June 10, 2007 Take a look at the sticky post labeled, HEADER ERRORS - READ HERE BEFORE POSTING THEM Quote Link to comment https://forums.phpfreaks.com/topic/54970-solved-headers/#findComment-271826 Share on other sites More sharing options...
spooke2k Posted June 10, 2007 Author Share Posted June 10, 2007 really dont get what u mean all i know is the code forces image download if its at the top and if its in my if statement the file becomes currpted when it comes down comes down and cant open it and im running out of ideas . Spooke2k Quote Link to comment https://forums.phpfreaks.com/topic/54970-solved-headers/#findComment-271865 Share on other sites More sharing options...
Hypnos Posted June 10, 2007 Share Posted June 10, 2007 You echoed before a header() function. http://www.phpfreaks.com/forums/index.php/topic,37442.0.html Quote Link to comment https://forums.phpfreaks.com/topic/54970-solved-headers/#findComment-271872 Share on other sites More sharing options...
spooke2k Posted June 10, 2007 Author Share Posted June 10, 2007 still not itworked i removed the echo call and it has made no difference the file is curropted when it comes down where as it the header is above if statment it works must be a way to get it working Quote Link to comment https://forums.phpfreaks.com/topic/54970-solved-headers/#findComment-271879 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.