SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    Pragmatic Programmer halfasleeps's Avatar
    Join Date
    Feb 2006
    Location
    Altoona, PA. USA
    Posts
    1,945
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    get uploaded file width and height??

    i am uploading a file, it will be wither an image file or an .swf (flash) file, is there anyway i can get the width and height of the file?


    heres my code:
    HTML Code:
    <input name="product_image_sm" type="file" id="product_image_sm" size="20">
    PHP Code:
    $image_name_sm basename($_FILES['product_image_sm']['name']); 


    THanks
    Altoona Design
    Freelance Flex developer for hire.
    ActionScript Programmer with 8 Years Experience.

  2. #2
    SitePoint Guru aamonkey's Avatar
    Join Date
    Sep 2004
    Location
    kansas
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    assuming that you have the gd library installed on your server, you can use getimagesize()

  3. #3
    Pragmatic Programmer halfasleeps's Avatar
    Join Date
    Feb 2006
    Location
    Altoona, PA. USA
    Posts
    1,945
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks man,

    that returns an array like this

    Array ( [0] => 550 [1] => 400 [2] => 13 [3] => width="550" height="400" [mime] => application/x-shockwave-flash ) image size = 1

    so [3] => width="550" height="400"

    how can i get that into 2 different vars for wdth and height???
    $w=550;
    $h=400;

    Thanks!
    Altoona Design
    Freelance Flex developer for hire.
    ActionScript Programmer with 8 Years Experience.

  4. #4
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    list($w$h) = getimagesize(); 

  5. #5
    SitePoint Guru aamonkey's Avatar
    Join Date
    Sep 2004
    Location
    kansas
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the first example on that page shows you how.

  6. #6
    Pragmatic Programmer halfasleeps's Avatar
    Join Date
    Feb 2006
    Location
    Altoona, PA. USA
    Posts
    1,945
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nevermind im a complete idiot i didnt realize [0] and [1] were the width and hiehgt thanks
    Altoona Design
    Freelance Flex developer for hire.
    ActionScript Programmer with 8 Years Experience.


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
  •