Image filter & handler

Discussion in 'PHP' started by junandya, Oct 20, 2007.

  1. #1
    Hello,...

    i have some problem with image filter in my form processor.

    1. As we know in string we have htmlspecialchars to counter unexpected script. how about file field, how to filter it. it seem impossible to use htmlspecialchars there, because sometimes a path fro a file use special character.

    2. how can i now the image extention, let say that i only receive file with jpg extention, & reject the other one.

    3. how can i now what is the image dimension (W & L), so i can reject an image with width size more than xxx pixel.

    I apriciate very much for your help
    Best Regards......
     
    junandya, Oct 20, 2007 IP
  2. Koster

    Koster Guest

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    For 2,3
    There are array getimagesize ( string filename [, array &imageinfo] ) fuction.
    imageinfo parameter: this optional parameter allows you to extract some extended information from the image file.

    Returns an array with 5 elements.
    Index 0 and 1 contains respectively the width and the height of the image.
    Index 2 is one of the IMAGETYPE_XXX constants indicating the type of the image (for JPG it is IMAGETYPE_JPEG).
     
    Koster, Oct 20, 2007 IP
  3. Koster

    Koster Guest

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Image types:
    IMAGETYPE_GIF image/gif
    IMAGETYPE_JPEG image/jpeg
    IMAGETYPE_PNG image/png
    IMAGETYPE_SWF application/x-shockwave-flash
    IMAGETYPE_PSD image/psd
    IMAGETYPE_BMP image/bmp
    IMAGETYPE_TIFF_II (intel byte order) image/tiff
    IMAGETYPE_TIFF_MM (motorola byte order) image/tiff
    IMAGETYPE_JPC application/octet-stream
    IMAGETYPE_JP2 image/jp2
    IMAGETYPE_JPX application/octet-stream
    IMAGETYPE_JB2 application/octet-stream
    IMAGETYPE_SWC application/x-shockwave-flash
    IMAGETYPE_IFF image/iff
    IMAGETYPE_WBMP image/vnd.wap.wbmp
    IMAGETYPE_XBM image/xbm
     
    Koster, Oct 20, 2007 IP