Re: Problem forcing a download

From: Date: Mon, 05 May 2003 20:03:26 +0000
Subject: Re: Problem forcing a download
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-146445@lists.php.net to get a copy of this message
"Kevin Stone" <kevin@helpelf.com> wrote in message news:029a01c31339$ebe605d0$6500a8c0@kevin... > > ----- 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 > > thank you for your reply, but where do i put readfile($_GET['file_name']);

« previous php.general (#146445) next »