Unlimited Usenet
day retention, 99% Completion, Unlimited Access, Free Trial!

Open "Save As" dialog on link *WORKING*

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'...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-19-2006
Lisa
 
Posts: n/a
Default Open "Save As" dialog on link *WORKING*


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

Reply With Quote
  #2 (permalink)  
Old 08-19-2006
Mumia W.
 
Posts: n/a
Default Re: Open "Save As" dialog on link *WORKING*

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
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 08:29 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0