change name of a file being uploaded

this is what I have right now:

if($_POST['uploadSubmit']){
      $uploaddir = '/home/httpd/vhosts/creationexpress.com/subdomains/admin/httpdocs/cards2/';
      $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."-".$_SESSION['clientId']."-"imageName.jpg

$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)

code-clientId-picture.jpg

thanks
jtrudeauAsked:
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"
0
 
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.
0
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.