change name of a file being uploaded

this is what I have right now:

      $uploaddir = '/home/httpd/vhosts/';
      $uploadfile = $uploaddir . $_FILES['fieldOne']['name'];
      if (move_uploaded_file($_FILES['fieldTwo']['tmp_name'], $uploadfile)) {
            chmod ($uploadfile, 0755);
            print("Successful !");
      } else {
            print("Unsuccessful !");

this uploades the file properly as named on the computer, however, what I want is:


$next is a auto increment variable (works properly when inserting in DB only)
$_SESSION['clientId'] is the client id variable (works properly when inserting in DB only)
then the name of the image as named on the computer (works properly)
in between variables I would like a - (hyphen)


Who is Participating?
Jaime OlivaresSoftware ArchitectCommented:
$uploadfile = $uploaddir . $_FILES['fieldOne']['name'];

According to your explanation, would be:
 $uploadfile = $uploaddir . $next . "-" . $_SESSION['clientId']."-".$_FILES['fieldOne']['name'].".jpg"
jtrudeauAuthor Commented:
I could have swore I tried that exact same thing and it didnt work I guess I was missing something somewhere, because yourw worked.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.