how to use GETIMAGESIZE() function

Discussion in 'PHP' started by Nandamuri, Jul 2, 2009.

  1. #1
    <?php
    $size = getimagesize($filename);
    $fp = fopen($filename, "rb");
    if ($size && $fp) {
        header("Content-type: {$size['mime']}");
        fpassthru($fp);
        exit;
    } else {
        // error
    }
    ?>
    
    PHP:
    I have replaced $filename with 'watermark.png'

    The result is http://crazyjunction.com/GD/1.php
     
    Nandamuri, Jul 2, 2009 IP
  2. gunbound

    gunbound Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    getimagesize() use to get the information of an image, this is example:
    your code is ok but http://crazyjunction.com/GD/1.php code error because you echo somethings above the header() function line
     
    gunbound, Jul 2, 2009 IP
  3. ivan.kristianto

    ivan.kristianto Active Member

    Messages:
    136
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #3
    ivan.kristianto, Jul 2, 2009 IP
  4. mdrobiul

    mdrobiul Peon

    Messages:
    186
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    never put echo about header()
     
    mdrobiul, Jul 3, 2009 IP