Headers outputting file to screen on live but starting download local
-
Hi,
I’m learning php and to start I have created a plugin for my photography site, The plugin has an admin area and makes use of a shortcode for adding to posts and pages,the idea is I sell download codes for the clients images. This plugins admin pages allow you to add a code to the db with a maximum download count and two filenames, the filename on the server (to prevent people from knowing and downloading the file without going through the process) and a filename you want the user to have…
when you add the shortcode it displays an input box and a button to your pages/posts allowing the viewer to enter the code and if its in the db and the max download count hasn’t been reached iniate the download.
now all my code works in a basic install of wp locally yet when i move it to the live site to test it does this :
http://www.ctwo12.com/output.png
it out puts the content of the file to the screen rather than offering up a download!
with php outputting enabled it says headers already sent by nav_template.php on line 240 then lists my file and the line number (i think that was it as I’m at work and on my mobile phone!)
any idea what’s going wrong? And why it works fine locally?
here are the headers I’m giving :
$fileonS = $_SERVER['DOCUMENT_ROOT'] . "/wp-content/plugins/photo_dwn_man/downloads/" . $codeRResult;//download file (NEEDS MORE LOOKING INTO THIS IS JUST THE BASICS)
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . $codeOResult . '.zip');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($fileonS));
ob_clean();
flush();
readfile($fileonS);
exit;I’m here to learn and not copy so please explain any answers so i can take that in and learn from it in future 😊
- The topic ‘Headers outputting file to screen on live but starting download local’ is closed to new replies.