upload files

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
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

upload files

Post by shiznatix »

i have a section that uploads a file, but i want the file name to be changed when it is uploaded. here is what im using

Code: Select all

if (move_uploaded_file($_FILESї'thefile']ї'tmp_name'], "avatars/{$_FILESї'thefile']ї'name']}")){
	echo 'ok good';
	}else
	echo 'Could Not Be Uploaded';
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

so change the name. :roll:
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

so i would change

Code: Select all

avatars/{$_FILESї'thefile']ї'name']}
to

Code: Select all

avatars/customfilename
?

would this retain the file extension?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

try it, find out for yourself.
Post Reply