...

View Full Version : Figuring out a files extension?



jc4p
01-24-2007, 07:16 AM
Hi,
I have a html page, where one can upload a file. Now the thing is, I can't figure out how to find the files extension in php! The html page's textbox is for a file, so it doesn't export the input of the textbox as a string, so I can not just look at everything past the dot.
I thought about making the php file read the file and see what the first letters in it were, and identify it by that, but the thing is that is going to take way too much time and way too many if commands. Does anyone know of a simpler way?

Fumigator
01-24-2007, 07:30 AM
The $_FILES['userfile']['type'] variable will give you the file type of an uploaded file. See Handling file uploads (http://us2.php.net/manual/en/features.file-upload.php) in the manual for more info.

jc4p
01-24-2007, 08:09 AM
The $_FILES['userfile']['type'] variable will give you the file type of an uploaded file. See Handling file uploads (http://us2.php.net/manual/en/features.file-upload.php) in the manual for more info.

Wow I feel stupid now. Thanks!

Fumigator
01-24-2007, 08:26 PM
No need to feel stupid, it's how we all learn stuff. Plus, feeling stupid is MY job! :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum