filesize() problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ganesanji
    New Member
    • Jun 2007
    • 16

    filesize() problem

    hi all,

    I have created a simple downloading script for a file which is given below[php]$f="images/52219-4.bmp";
    $ftype = mime_content_ty pe($f);
    $fsize= filesize($f);
    header("Content-type: \"".$ftype."\"" );
    header("Content-Disposition: attachment; filename=\"".$f ."\"");
    header("Content-length:".$fsize );
    readfile($f);
    exit;[/php] Even this script downloads the image, the downloaded file size is 0 bytes.

    What is wrong in this script or i have to add any more headers?
    Plz anybody help me....
    I am looking forward for your valuable suggestions and solutions.....

    Advance thanks,
    Last edited by ronverdonk; Apr 24 '08, 03:31 PM. Reason: use code tags!
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    WARNING:
    Please enclose your posted code in [code] tags (See How to Ask a Question).

    This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

    Please use [code] tags in future.

    MODERATOR

    Comment

    • TheServant
      Recognized Expert Top Contributor
      • Feb 2008
      • 1168

      #3
      Originally posted by ganesanji
      hi all,

      I have created a simple downloading script for a file which is given below[php]$f="images/52219-4.bmp";
      $ftype = mime_content_ty pe($f);
      $fsize= filesize($f);
      header("Content-type: \"".$ftype."\"" );
      header("Content-Disposition: attachment; filename=\"".$f ."\"");
      header("Content-length:".$fsize );
      readfile($f);
      exit;[/php] Even this script downloads the image, the downloaded file size is 0 bytes.

      What is wrong in this script or i have to add any more headers?
      Plz anybody help me....
      I am looking forward for your valuable suggestions and solutions.....

      Advance thanks,

      Never used fsize, but have you tried echoing $fsize and seeing if it is the headers or the use of the function?

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        I can see no immediate problem. I have tried this code on my own system and it downloads my .bmp entirely, except for the funny name that is generated by default. That is because you have the path name as part of the output file name in your header and it will not accept the forward slash. But besides that, it is fine.

        Ronald

        Comment

        Working...