note 39032 added to function.readfile
| From: | acwebdesign at socal dot rr dot com | Date: | Thu, 15 Jan 2004 04:09:33 +0000 |
| Subject: | note 39032 added to function.readfile | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-63578@lists.php.net to get a copy of this message | ||
I am trying to make a force-download and then delete file for PDFs. It seems the headers (and
possibly the readfile - experiementing gives mixed messages) execute, but any scripts after that do
not execute, i.e. unlink($filename).
This is a simplified version of what I have:
$file_to_download=$_GET["filename"];
$filename=$_GET["filename"];
header("Content-Type: application/force-download");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($file_to_download));
header("Content-Disposition: attachment; filename=$filename");}
if(readfile($file_to_download)==filesize($file_to_download)) //download, and ask if file downloaded
100%
{
if(!unlink($file_to_download))//if not delete.
{
exit("Tried to delete file, however error occured. Possible cause: file name invalid.
Record will not be deleted.");
}
else{
echo "Downloaded and deleted.<br>";
}
}//if not download
else exit("File did not download 100%, therefore it will not be deleted.");
If anyone has ANY idea/help, Please email me!
----
Manual Page -- http://www.php.net/manual/en/function.readfile.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+39032
Delete -- http://master.php.net/manage/user-notes.php?action=delete+39032&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+39032&report=yes
Search -- http://master.php.net/manage/user-notes.php