0

There are lots of questions about renaming files when they are uploaded. What I'd like to do is take it a step further.

Is there a way to have my users answer some questions and then name a file they've uploaded based on their answers?

For example: a user answers the questions, "what is your name?" "what is the number of your document?" "what is your department?" with: "Bob", "44", and "Programming" respectively.

Then then upload their document. The system then renames their document "Programming_bob_044" and – for good measure – maybe throws in the date too?

Is there a way to do this? Thank you!

Isaac
  • 1
  • 1

1 Answers1

0
$img_dir = "upload/";
$temp = explode(".", $_FILES["file"]["name"]);
$img = $img_dir .$_POST['job'].'_'.$_POST['name'].'_'.$_POST['age'].'.' .end($temp);
move_uploaded_file($_FILES['file']['tmp_name'], $img);

Try this code. You get the answers with POST then put it in your image name

Osman Omar
  • 433
  • 1
  • 7
  • 19