|
|
 Brian Williams | 2006-08-06 18:53:32 |
Hi, I really like this class, it makes for quick and easy filtered fileuploads to prevent suspicious file uploads, not to mention image handling and multiple file uploads.
So obviously I'm using this class on my site, but i want to be able to rename the file to avoid duplicate file names.
I've managed to get the file saved as a different name, however i just can't figure out how to keep the original extension, eg. .doc .txt .html etc..
aka i want to rename file.doc to user.section.doc or file.txt to user.section.txt
like i said i've got the user.section. part figured out, it's just the extension that is giving me problems.
any help would be great.
thanks! |
| |
2. Re: file extension |
|
Reply |
|
|
 Steve Rumberg | 2007-09-17 18:00:03 - In reply to message 1 from Brian Williams |
I have just downloaded this class and have not examined the code at all, but here's how I have been getting the extension of a file:
# get the name of the file that was submitted for uploading
$filename = basename($_FILES[$html_form_field_name]['name']);
# get the extension of the file submitted to be uploaded
$extension = strtolower(substr($filename, strrpos($filename, '.') + 1));
Hope this helps...
Steve |
|