Results 1 to 2 of 2
  1. #1
    Question JPEG file download via PHP on Mac(IE)
    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:

    $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
    //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.

  2. #2

    Murlyn's Avatar
    Member Since
    Jun 11, 2003
    Mount Vernon, WA
    MacBook Pro 2.6 GHz Core 2 Duo 4GB RAM OS 10.5.2
    The quickest way would be by zipping it up or gzipping it, then output that way, since all browsers know to download a zip file or tgz file etc... I havent had to deal with that in a long time so I couldnt tell you right off the top of my head.

    Also renaming the .php file that was downloaded to .jpg works.. just an extra step...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How Can I Save Date Stamp to JPEG file HELP
    By dandg in forum Images, Graphic Design, and Digital Photography
    Replies: 2
    Last Post: 01-24-2012, 07:17 AM
  2. Convert Tif file to a Jpeg file
    By RayH in forum OS X - Operating System
    Replies: 2
    Last Post: 11-24-2011, 08:55 PM
  3. trying to get a jpeg to play as a video file for 13 mins
    By czarthp in forum Movies and Video
    Replies: 3
    Last Post: 08-28-2010, 04:51 PM
  4. JPEG File Locked
    By deayala1 in forum Apple Desktops
    Replies: 2
    Last Post: 06-18-2010, 05:17 PM
  5. Name of jpeg file
    By sbvishal in forum OS X - Apps and Games
    Replies: 0
    Last Post: 04-03-2008, 12:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts