Re: DOWNLOAD

From: Date: Tue, 21 Jan 2003 16:57:27 +0000
Subject: Re: DOWNLOAD
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-132455@lists.php.net to get a copy of this message
People often for get about a little problem that happens with the <? $name_the_file = "the name you want the file to be called when prompted to download"; $file_to_download = "/path/to/file/filename.scp"; // test for internet explorer in the conditional for the following if..then..else if (msie) { $attachment=""; } else { $attachment=" attachment;"; } header("Content-Type: application/download\n"); header("Content-Disposition:$attachment filename=\"$name_the_file\""); readfile("$file_to_download"); exit(); ?> I found a bug when developing a download script a year or so ago. You can't have the 'attachment;' part in IE. It did some funky stuff and netscape 4 would die without it. Jim ----- Original Message ----- From: "Timothy Hitchens (HiTCHO)" <hitcho@php.net> To: "'Shaun van den Berg'" <shaun@novtel.co.za>; <php-general@lists.php.net> Sent: Tuesday, January 21, 2003 1:44 AM Subject: RE: [PHP] DOWNLOAD > Create a script that reads the contents of a file after sending headers > eg: > > header("Content-type: text/plain"); > header("Content-Disposition: attachment; filename=downloaded.txt"); > readfile("downloaded.txt"); > exit(); > > The downloaded.txt can be any file subject to sending the correct > headers and IE > and other browsers will pop up a download (save) window. > > See your mime.types file for headers for each file type. > > > Timothy Hitchens (HiTCHO) > Open Source Consulting > e-mail: tim@hitcho.com.au > > > -----Original Message----- > > From: Shaun van den Berg [mailto:shaun@novtel.co.za] > > Sent: Tuesday, 21 January 2003 4:39 PM > > To: php-general@lists.php.net > > Subject: [PHP] DOWNLOAD > > > > > > Hi , > > > > Im not sure if this can be done in PHP , i know PHP has > > upload features ! Does it have download features , wat i mean > > is the following : i want a link - click here to download - > > when you click on it , the download dialog box must appear - > > how do i do this ? > > > > Thanks > > Shaun van den Berg > > > > -- > > Novtel Consulting > > Tel: +27 21 9822373 > > Fax: +27 21 9815846 > > Please visit our website: > > www.novtel.co.za > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#132455) next »