php code to save files on user machine

I was trying to save the ‘.xls’, ‘.doc’, ‘.wmv’ on user machine, which works correctly on Firefox(developer friendly) but not on Microsoft’s IE(Microsoft friendly); after searching on the net, i found this code which works on both the browser. here is the code: ————————- <?php // downloading a file $filename = $_GET[‘path’]; // fix for […]

PHP Script to load a PDF

To get PHP to load a PDF (for example) from file, use the following code. <?php $filename = $_SERVER[‘DOCUMENT_ROOT’] . “/path/to/file/my_file.pdf”; header(“Cache-Control: public”); header(“Content-Description: File Transfer”); header(‘Content-disposition: attachment; filename=’.basename($filename)); header(“Content-Type: application/pdf”); header(“Content-Transfer-Encoding: binary”); header(‘Content-Length: ‘. filesize($filename)); readfile($filename); ?>

Cannot modify header information – headers already sent

Warning: Cannot modify header information – headers already sent by (output started at /home/domain/public_html/file.php:42) in home/domain/public_html/includes/main.php on line 302 Solution The “headers already sent” error is usually caused by having white space before or after the opening and closing PHP tags (<?php . . . ?>). Remove the additional spaces , this should solve the […]