Fw: [PHP] Problem forcing a download

From: Date: Mon, 05 May 2003 19:09:43 +0000
Subject: Fw: [PHP] Problem forcing a download
Groups: php.general 
Request: Send a blank email to php-general+get-146443@lists.php.net to get a copy of this message
----- Original Message ----- From: "shaun" <shaun@mania.plus.com> To: <php-general@lists.php.net> Sent: Monday, May 05, 2003 12:46 PM Subject: [PHP] Problem forcing a download > Hi, > > I am trying to force licks to files to open a file save dialog box, whatever > the file type is. > > I have the following link on my page (the page links back to itself): > > <p>Click <a > href="view_document.php?file_name='.$file_name.'&view_document=true">here</a > > to download the document</p>'; > > I also include a file at the top of each page (top.php) for function calls > and in this file I have the following: > > //view document > if(isset($_GET[view_document]) == true){ > Header('Content-Type: application/octet-stream'); > Header('Content-disposition: attachment; filename='.$_GET[file_name]); > } > > when I click on the link I get the dialog box popping up but it downloads > the code for view_document.php. > > I am obviously doing something silly here but I can't work it out, I would > be very grateful for you advice here. When are you outputing the file? readfile($_GET['file_name']); after header. - Kevin

« previous php.general (#146443) next »