On Fri, 2009-08-28 at 15:03 -0400, Dan Shirah wrote:

> Greetings,
> 
> I'm having a problem trying to get a file download prompt.
> 
> Basically I have a page with image links.
> 
> When the link is clicked, the user is directed to another page I have. That
> page finds the image path based on the image ID from the previous page.
> 
> Once the image path is found I copy the image to the local webserver and
> rename the proprietary extension, .0D9 to .tif
> 
> Once the file is renamed to .tif I want the download prompt to come up.  You
> know, where it says, "Open" "Save" "Cancel".
> 
> I've tried using:
> 
> $fp = fopen($new_file,"r") ;
> header("Content-Type: image/tif");
> while (! feof($fp)) {
>        $buff = fread($fp,filesize($new_file));
>        print $buff;
>        }
> 
> But that just gives me heiroglyphics on the screen instead of prompting the
> user to download.
> 
> Here is my code that copies and renames the file:
> 
> if ($page != "" || $page != " ") {
>  exec("xcopy ".$page." ".$topage."");
> }
> $orig_file = $topage."\\".$objectid.".0D9";
> //echo $orig_file;
> $new_file = $topage."\\".$objectid.".tif";
> //echo $new_file;
> 
> rename($orig_file,$new_file);
> 
> Any ideas on how to make the browser give the download prompt for $new_file?
> 
> Thanks,
> Dan

You need to send down the right headers to the browser, so that it knows
it's meant to save the file, and not attempt to display it. If the link
was to a file, you'd have certain header that informed the browser the
mime type of the file.

Thanks,
Ash
http://www.ashleysheridan.co.uk


Reply via email to