• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 276
  • Last Modified:

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
0
jtrudeau
Asked:
jtrudeau
1 Solution
 
Jaime OlivaresCommented:
$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

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now