how to add variable to filename

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
lcramer
Forum Newbie
Posts: 1
Joined: Sat Aug 09, 2008 8:37 am

how to add variable to filename

Post by lcramer »

How can I 'rename' a file that php is uploading by inserting the 'label' (from the form) 'name'?

ex: uploaded file original name = wedding1.jpg
name label = jane doe

renamed uploaded file saved to server would = wedding1janedoe.jpg

What code would I have to put in to the php script?

Any help, thank you!
L
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: how to add variable to filename

Post by pickle »

strip the extension (strrpos() might help there), add what you want, then tack the extension back on.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply