This is a discussion on Open "Save As" dialog on link *WORKING* within the PHP General forums, part of the PHP Programming Forums category; hi, i am trying to have a link to download a jpg directly, not display it in the browser. i'...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
hi, i am trying to have a link to download a jpg directly, not display it in the browser. i've got <?php if(isset($filename)): $headertxt = "Content-Disposition: attachment; filename=\"".$filename."\""; header("Content-Type: application/force-download");header($headertxt); include("$filename"); endif; ?> it works fine for opening an html or text files, it prompts me to save and does so properly. however on jpg it prompts me to save as well, but only saves <b>Parse error</b>: syntax error, unexpected T_STRING in <b>/test.jpg</b> on line <b>93</b><br /> any help or suggestions would be greatly appreciated! thanks, lisa |
|
|||
|
On 08/18/2006 07:21 PM, Lisa wrote:
> hi, Hello. > i am trying to have a link to download a jpg directly, not display it > in the browser. > > i've got > > <?php > if(isset($filename)): > $headertxt = "Content-Disposition: attachment; > filename=\"".$filename."\""; > header("Content-Type: > application/force-download");header($headertxt); > include("$filename"); > endif; > ?> > > it works fine for opening an html or text files, it prompts me to save > and does so properly. > however on jpg it prompts me to save as well, but only saves > > > <b>Parse error</b>: syntax error, unexpected T_STRING in > <b>/test.jpg</b> on line <b>93</b><br /> > > > any help or suggestions would be greatly appreciated! > thanks, > lisa > Perhaps you want to use fopen and fpassthru to send the jpeg file to the user. You should test to ensure that the file is not something you don't want the world to see. What if a hacker invokes your script like so? http://example.org/myscript.php?filename=/etc/passwd |