renaming upload file to be a name feild

User 2808808 Photo


Registered User
1 post

I need a simple file to be uploaded and renamed to be the typed field.

so if I have a box for the user to type in a number then make that number the name of the file they uploaded
User 187934 Photo


Senior Advisor
20,241 posts
Online Now

Hi JD,
Here's a quick example

$image_name = $_POST['inputname'];
$extension = end(explode(".", $_FILES["photo"]["name"]));
$directory = 'myphotos';
if (!file_exists('../'.$directory)) {
mkdir('../'.$directory, 0777, true);
}
move_uploaded_file($_FILES["photo"]["tmp_name"],
'../'.$directory.'/'.$image_name.'.'.$extension );
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.