note 56430 added to function.header
| From: | seema_killedar at nucsoft dot co dot in | Date: | Fri, 02 Sep 2005 09:55:28 +0000 |
| Subject: | note 56430 added to function.header | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-94651@lists.php.net to get a copy of this message | ||
you can follow following sample code for preparing a download link :
downloadLink.php
================================
<?
print "please click " ;
print "<a href=\"./downloadAction.php?fileName=download.pdf\">";
print "here";
print "</a>";
print "to download. ";
?>
================================
This page will call "downloadAction.php" on click of the text "here".
downloadAction.php
====================
<?
$filename = $_GET['fileName'];
$path="C:/download/";
/*print "filename ".$filename;
print "path ".$path;*/
header('Pragma: private');
header('Cache-control: private, must-revalidate');
header("Content-type: text/x-ms-iqy");
$fp = fopen($path.$filename,"r");
$filedata=fread($fp,filesize($path.$filename));
fclose($fp);
header("Content-type: text/x-ms-iqy");
header("Content-Disposition: attachment; filename=".$filename);
print $filedata;
?>
================================
Dont forget to put a file with a name "download.pdf" in the folder "C:\download
"(or any path)
I hope this will work for u.
thanks,
best luck.
----
Manual Page -- http://www.php.net/manual/en/function.header.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+56430
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56430&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56430&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56430&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56430&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56430&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56430&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+56430&report=yes
Search -- http://master.php.net/manage/user-notes.php