ciao ragazzi!

ottengo l'errore "Problems during the upload of the file" nonostante ci sia il chmod 777 settato correttamente.

quale può essere il problema?

Codice PHP:
 if ($_POST["upload"] == "upload") {
  if(!isset(
$_FILES)) $_FILES $HTTP_POST_FILES;
  if(!isset(
$_SERVER)) $_SERVER $HTTP_SERVER_VARS;

  
$upload_dir "../gallery/images"//chmod 777
  
$upload_dir1 $upload_dir."_".$_POST["ngallery"]."/";
  
$upload_dir2 $upload_dir."_".$_POST["ngallery"]."/thumbs_".$_POST["ngallery"]."/";
  
$new_name $_POST["newname"];
  
$file_name1 = ($new_name) ? $new_name $_FILES["upfile1"]["name"];
  
$file_name2 "TN_".$file_name1;

  echo 
"<script>alert('UPLOAD DIR 1 :: ".$upload_dir1."');alert('UPLOAD DIR 2 :: ".$upload_dir2."');alert('FILENAME 1 :: ".$file_name1."');alert('FILENAME 1 :: ".$file_name2."');</script>";
  
  if(
trim($_FILES["upfile1"]["name"]) == "" || trim($_FILES["upfile2"]["name"]) == "") {
   
$mex "You must select two files to be uploaded";
  }
  if(@
is_uploaded_file($_FILES["upfile1"]["tmp_name"]) && @is_uploaded_file($_FILES["upfile2"]["tmp_name"])) {
   @
move_uploaded_file($_FILES["upfile1"]["tmp_name"], "$upload_dir1/$file_name")
    or die(
"Moving the first file is impossible, check the existence or the permissions of the directory where you upload.");
   @
move_uploaded_file($_FILES["upfile2"]["tmp_name"], "$upload_dir2/$file_name")
    or die(
"Moving the second file is impossible, check the existence or the permissions of the directory where you upload.");
  }
  else {
   
$mex "Problems during the upload of the file " $_FILES["upfile"]["name"];
  }
  if (
$mex == "") { $mex "Files successfully uploaded"; }
 } 
grazie mille!

ciau ciau