Professional Web Applications Themes

Problem with forced downloads via HTTP headers.. - PHP Development

Hello, Can anyone verify / solve the problem I am having with downloading an image.. The following test works fine in every browser I've tried except in mozilla for windows. Mozilla appends .php to the file name when prompted to save or open. In IE, I can save it to disk or open it, and the associated program opens the file. In Mozilla, it can't open the file because it displays the file like ... somefile.jpg.php Any ideas why? <?php $fpath = "../tmp/"; $fname = "somefile.jpg"; header( "Pragma: no-cache\n" ); header( "Content-type: image/jpg\n" ); header( "Content-Disposition: attachment; filename=\"$fname\"\n" ); header( ...

  1. #1

    Default Problem with forced downloads via HTTP headers..

    Hello,

    Can anyone verify / solve the problem I am having with downloading an
    image..

    The following test works fine in every browser I've tried except in mozilla
    for windows. Mozilla appends .php to the file name when prompted to save or
    open. In IE, I can save it to disk or open it, and the associated program
    opens the file. In Mozilla, it can't open the file because it displays the
    file like ... somefile.jpg.php

    Any ideas why?

    <?php
    $fpath = "../tmp/";
    $fname = "somefile.jpg";

    header( "Pragma: no-cache\n" );
    header( "Content-type: image/jpg\n" );
    header( "Content-Disposition: attachment; filename=\"$fname\"\n" );
    header( "Content-transfer-encoding: binary\n" );
    header( "Content-length: " . filesize($fpath . $fname) . "\n" );

    $fd = fopen($fpath . $fname, 'rb');

    while( !feof($fd) )
    {
    echo fread($fd, 4096);
    flush();
    }
    fclose( $fd );
    ?>


    Magnetotron Guest

  2. #2

    Default Re: [PHP] Problem with forced downloads via HTTP headers..

    * Thus wrote Magnetotron (magnetotronhotmail.com):
    > Can anyone verify / solve the problem I am having with downloading an
    > image..
    >
    > <?php
    > $fpath = "../tmp/";
    > $fname = "somefile.jpg";
    >
    > header( "Pragma: no-cache\n" );
    > header( "Content-type: image/jpg\n" );
    Should be image/jpeg.
    > header( "Content-Disposition: attachment; filename=\"$fname\"\n" );
    Don't know if that is the problem but its worth a shot right now,
    mozilla usually is more trusting with reading headers than IE.

    Curt
    --
    "I used to think I was indecisive, but now I'm not so sure."
    Curt Zirzow Guest

  3. #3

    Default Re: [PHP] Problem with forced downloads via HTTP headers..

    Ok, I changed it to image/jpeg, and now the filename is....
    somefile.jpg.jpeg

    No matter what I do, Mozilla for windows wants to append another extension
    on the filename based on the mime type. Mozilla under linux works fine...

    "Curt Zirzow" <curtzirzow.dyndns.org> wrote in message
    news:20030812010721.GR379bagend.shire...
    > * Thus wrote Magnetotron (magnetotronhotmail.com):
    > > Can anyone verify / solve the problem I am having with downloading an
    > > image..
    > >
    > > <?php
    > > $fpath = "../tmp/";
    > > $fname = "somefile.jpg";
    > >
    > > header( "Pragma: no-cache\n" );
    > > header( "Content-type: image/jpg\n" );
    >
    > Should be image/jpeg.
    >
    > > header( "Content-Disposition: attachment; filename=\"$fname\"\n" );
    >
    > Don't know if that is the problem but its worth a shot right now,
    > mozilla usually is more trusting with reading headers than IE.
    >
    > Curt
    > --
    > "I used to think I was indecisive, but now I'm not so sure."

    Magnetotron Guest

Similar Threads

  1. Http headers...
    By zperetz in forum ASP
    Replies: 0
    Last Post: July 20th, 03:31 PM
  2. http request headers
    By Chetan Ganjihal in forum PERL Modules
    Replies: 3
    Last Post: October 1st, 06:07 PM
  3. HTTP Headers
    By Martien Verbruggen in forum PERL Miscellaneous
    Replies: 3
    Last Post: September 7th, 06:44 AM
  4. Replies: 0
    Last Post: August 6th, 07:11 AM
  5. Getting all http headers
    By Arthur in forum ASP.NET Web Services
    Replies: 2
    Last Post: August 4th, 07:00 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139