note 56430 deleted from function.header by bjori
| From: | bjori@php.net | Date: | Mon, 27 Mar 2006 09:47:02 +0000 |
| Subject: | note 56430 deleted from function.header by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-106714@lists.php.net to get a copy of this message | ||
Note Submitter: seema_killedar at nucsoft dot co dot in
----
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.