PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 9th, 2005, 03:50 PM
positron positron is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 1 positron User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 30 sec
Reputation Power: 0
Unhappy JPEG file download via PHP on Mac(IE)

I know this is a Mac question, and even worse, IE on Mac, but ... I am trying to download a JPG file through a php page. The code is pretty straight forward, it obtains the filename from the query string, reads the file and outputs to the browser. Here is the code:

<?php
$filename = $_GET["file"];
$bytes = filesize("PATH_TO_FOLDER/$filename");
header("Content-type: application/jpg");
header("Content-disposition: attachment; filename=\"$filename\"");
header("Content-length: $bytes");
//Read the file and output to browser
@readfile("PATH_TO_FOLDER/$filename");
//Code to record the download in database
?>

Originally I had "Content-type: image/jpeg"), but later on changed to "application/jpg" after reading through some forums on web. Both the content-types work fine in all browsers on a Windows PC, but they behave very differently with IE5.2 on MacOSX and IE5.1 on Mac OS9. The "Save As.." box does not open and the image gets displayed directly on the window. If I try to save the image by Ctrl+Click and Download to Disk, it shows the filename as "download.php" instead of the correct name "FILENAME.jpg" given in the Content-disposition header.

I did a lot of google and read in several forums that IE on Mac ignores the Content-disposition header. Is there any workaround for this. My aim is to display the "Save As.." dialog box on Mac IE (OSX and OS9), display the correct filename in the save as dialog box and allow the user to save the file through the dialog box.

(In Mozilla (Mac) it will download the file (but you have to be very quick as it tends to close the "What should Mozilla do with this file?" dialog quickly if you don't select the 'save' option and click 'ok'). Safari seems to be the only browser happy to download a .jpg file onto the disk.)

Any suggestions or pointers would be appreciated (other than dump the Mac)

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > JPEG file download via PHP on Mac(IE)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT