[Problem] Uploading files - changing names....

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Mr. Tech
Forum Contributor
Posts: 205
Joined: Tue Feb 11, 2003 4:18 pm
Location: Australia

[Problem] Uploading files - changing names....

Post by Mr. Tech »

Hi!

I have this uploading script but I can't work out how to rename the file. Also, the only file extensions I want it to accept is .gif, .jpf and .png.

I searched but to many posts...

Thanks for any help!!!
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

you might use http://www.php.net/manual/en/function.m ... d-file.php

Code: Select all

<input type="file" name="ufile" maxlength="345678" accept="image/*" />
advises the browser that only image-mimetypes should be accepted (not trustworthy)
Using pathinfo() you can get the extension of the file and check it.
For supported image types getimagesize() can help you to retrieve the file(mime)type
Haven't checked the php4.3+ function mime_content_type() but it should do almost the same as executing the shell command file on a unix-system
Post Reply