SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    :) delemtri's Avatar
    Join Date
    Jun 2001
    Posts
    579
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    filename ext out of an uploaded file

    How would I get the file extension of an uploaded file?

  2. #2
    SitePoint Addict lveale's Avatar
    Join Date
    Jun 2001
    Location
    Dublin
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $fileExt strstr(file_name"."); // one way 

  3. #3
    :) delemtri's Avatar
    Join Date
    Jun 2001
    Posts
    579
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $file_name! Never knew that was part of the form data. Thanks a bunch!

  4. #4
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by lveale
    PHP Code:
    $fileExt strstr(file_name"."); // one way 
    that won't work if the filename has a period in it somewhere else (e.g. file.php.txt). use this:

    PHP Code:
    $ext substr(strrchr($file_name'.'), 1); 
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  5. #5
    SitePoint Addict lveale's Avatar
    Join Date
    Jun 2001
    Location
    Dublin
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    even better, well spotted Doc

  6. #6
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by delemtri
    $file_name! Never knew that was part of the form data. Thanks a bunch!
    Yep. Cool, huh? I believe there are three: if your uploaded file is held in the $file variable, you should be able to access $file_name, $file_size, and $file_type.


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
  •