RE: [PHP] Problem forcing a download
| From: | Jennifer Goodie | Date: | Mon, 05 May 2003 21:01:50 +0000 |
| Subject: | RE: [PHP] Problem forcing a download | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-146451@lists.php.net to get a copy of this message | ||
Is the rest of the code in the page in an else{}? Other wise your page is
going to continue down. Have you tried putting an exit() in after the
readfile?
> //view document
> if(isset($_GET[view_document]) == true){
> Header('Content-Type: application/octet-stream');
> Header('Content-disposition: attachment; filename='.$_GET['file_name']);
> readfile('files/'.$_GET['file_name']);
> }
>
> but it seems to be downloading the contents of test.txt followed
> by the code
> for view_document.php, any ideas why this is happening?
>
> Here is the link I call with:
>
> echo '<p>Click <a
> href="view_document.php?file_name='.$file_name.'&file_id='.$file_i
> d.'&projec
> t_name='.$_GET[project_name].'&project_id='.$_GET[project_id].'&vi
> ew_documen
> t=true">here</a> to download the document</p>';
>
> Thanks again.