note 10322 deleted from function.header by jimw
| From: | jimw@php.net | Date: | Wed, 31 Oct 2001 21:46:04 +0000 |
| Subject: | note 10322 deleted from function.header by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-19756@lists.php.net to get a copy of this message | ||
In response to webmaster@digitalshrine.com's post, it does work with netscape. I just finished
a download script and it gives lets me save it as a filename (I am using Netscape v4.75). You can
verify this and download something from http://www.vrillusions.com/downloads.shtml.
Here is what my basic setup looks like:
$file_ext = substr($file_filename, -4);
if($file_ext == ".txt") { $content_type = "text/plain"; }
else { $content_type = "application/octet-stream"; }
$full_file_path = $file_path."/".$file_filename;
header("Content-Type: $content_type");
header("Content-Disposition: atachment; filename=$file_filename");
header("Content-Length: ".filesize($full_file_path));
readfile($full_file_path);
exit();
now $file_filename is what I get when I access the datafile and is something like textfile.txt or
application.exe or archive.zip etc. and the $file_path is the absolute directory (ie,
/usr/home/files) so I can actually place the files from outside the webdirecotry, making it almoast
imposible to leech. Just make sure any files that need to be viewed in ASCII (php, html, perl, txt,
etc) have a content type of text/plain or it won't download right.