homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Gold Sponsor 2015!
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Simple downoad file script problem

10+ Year Member

Msg#: 3326995 posted 2:44 am on May 1, 2007 (gmt 0)

I'm having a "get.php" script as dumb as this:


// get.php

header('Content-Type: image/jpeg');
header('Content-Disposition: attachment; filename="KG800_01L.jpg"');
header('Accept-Ranges: bytes');
header('Pragma: no-cache');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-transfer-encoding: binary');
header('Content-length: ' . @filesize('KG800_01L.jpg'));


Which works OK on IE and FireFox, but on the browser from my mobile phones it tries to download the "get.php" file, instead of downloading the image file.

Is there something missing on that script? I really need to make the browser capable of retrieving the file this way, thanks.



WebmasterWorld Senior Member eelixduppy us a WebmasterWorld Top Contributor of All Time 5+ Year Member

Msg#: 3326995 posted 12:32 pm on May 1, 2007 (gmt 0)

I don't see anything reading through it quickly. It cannot download the php file, however, as it is already interpreted and sent out by the server. By downloading the "php" file, it should be downloading the image file because that it what the script is outputing. I do not work with mobile browsers at all, so maybe someone else can shed some light on your situation.

I wish you luck! :)


5+ Year Member

Msg#: 3326995 posted 9:32 pm on May 1, 2007 (gmt 0)

yes, it will still download the picture, but mobile browser has some problems with determining file name.

header('Content-Disposition: attachment; filename="KG800_01L.jpg"');

Try removing quotes surrounding file name, like

header('Content-Disposition: attachment; filename=KG800_01L.jpg');

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved