Content-Disposition: attachment; filename='' suggestst wrong filename

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • spike

    #1

    Content-Disposition: attachment; filename='' suggestst wrong filename

    I have a script that i use for my downloadable files.
    Bu when i try to download a file with IE it suggests a different
    filename
    than what i wrote in the code.

    For example. If i try to download the file 'download.test. zip' it
    suggests
    'download[1].test.zip' instead.

    I i use Mozilla Firefox to download the file it works fine...
    And another question: what does the @-character before
    require('includ es/sys.dbconnect.p hp') really do? :)

    I think i read it somewhere but i cant seem to remember what it
    means...

    Thanks

    code:
    -------------------------------------------------------------------------
    <?php
    if(IsSet($_GET['id']))
    {
    $fileid = $_GET['id'];
    $query = "SELECT sFilename FROM tblFiles WHERE fileId=" . $fileid .
    ";";
    $updatequery = "UPDATE tblFiles SET iHits=(iHits + 1) WHERE
    fileId=" . $fileid . ";";
    if(@require('in cludes/sys.dbconnect.p hp'))
    {
    if($result = mysql_query($qu ery))
    {
    if($rad = mysql_fetch_arr ay($result))
    {
    if(mysql_query( $updatequery))
    {
    header('Content-type: application/x-download');
    header('Content-Disposition: attachment; filename="' .
    $rad[0] . '"');
    header("Content-Length: " . filesize("../files/" .
    $rad[0]));
    readfile("../files/" . $rad[0]);
    }
    }
    else
    {
    echo "The file does not exist.";
    }
    }
    else
    {
    echo "SQL Error.";
    }
    }
    }
    else
    {
    header('Locatio n: http://www.google.com' );
    }
    exit();
    ?>
  • Tomislav Petrovic

    #2
    Re: Content-Disposition: attachment; filename='' suggestst wrong filename

    spike wrote:[color=blue]
    > And another question: what does the @-character before
    > require('includ es/sys.dbconnect.p hp') really do? :)[/color]

    @ means not to display any errors that a function behind
    it might display(encount er)...
    So in this case if you do not have includes/sys.dbconnect.p hp
    it will not display error/warning that you do not have it....

    Tomy.


    Comment

    • R. Rajesh Jeba Anbiah

      #3
      Re: Content-Disposition: attachment; filename='' suggestst wrong filename

      joan@ljungh.se (spike) wrote in message news:<667b15ba. 0405190530.7e96 8cbe@posting.go ogle.com>...[color=blue]
      > I have a script that i use for my downloadable files.
      > Bu when i try to download a file with IE it suggests a different
      > filename
      > than what i wrote in the code.
      >
      > For example. If i try to download the file 'download.test. zip' it
      > suggests
      > 'download[1].test.zip' instead.[/color]

      This topic has been already discussed here. It seems to be a
      problem with IE. Try to use only one period in the filename eg.
      download.zip

      --
      | Just another PHP saint |
      Email: rrjanbiah-at-Y!com

      Comment

      Working...