Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
// if everything is ok, try to upload file
} else {

$oldname = ['tmp_name'];
$newname =  $_SESSION['username']; '.' + $imageFileType;

if (rename($oldname, $newname)) {
  $message = sprintf(
    '',
    $oldname,
    $newname
  );
} else {
  $message = sprintf(
    '',
    $oldname
  );
}
  if (move_uploaded_file($_FILES["fileToUpload"], $newname, $target_file)) {
    echo "The file ". htmlspecialchars( basename("image has been uploaded.")
  ) else { // here my error happens -_-
    echo "there was an error uploading your file.";
  }
}
?>

error is syntax error unexpected, t_else, expecting error or ';'

What I have tried:

i tried adding braces and stuff searched from stack again lol i googled
Posted
Updated 5-Feb-22 3:40am

1 solution

// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
  echo "";
// if everything is ok, try to upload file
} else {

$oldname = ['tmp_name'];
$newname =  $_SESSION['username']; '.' + $imageFileType;

if (rename($oldname, $newname)) {
  $message = sprintf(
    '',
    $oldname,
    $newname
  );
} else {
  $message = sprintf(
    '',
    $oldname
  );
}
  if (move_uploaded_file($_FILES["fileToUpload"], $newname, $target_file)) {
    echo "The file ". htmlspecialchars( basename("image has been uploaded."));
   } else {
    echo "there was an error uploading your file.";
  }
}
?>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900