Giuliano

Download forzato di files


27-Dec-2000 08:17In 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.