$_FILES multiples...

$_FILES multiples... - PHP - Programmation

Marsh Posté le 29-01-2004 à 11:35:56    

j'essaie de charger plusieurs fichiers en même temps sur ma page...simplement je sais pas pourquoi les données s'enregistrent pas dans ma bdd...
 
HELP ME PLEASE !
 

Code :
  1. if ($submit)
  2. {
  3. include("../includes/fonctions.php" );
  4. $smartdate=date("dmy" );
  5. $smartnum=md5 (uniqid (rand()));
  6. $smartnum2=substr($smartnum,0,5);
  7. $batnum="BAT".$smartdate.$smartnum2;
  8. $_SESSION['batnum']=$batnum;
  9. $_SESSION['email']=$_POST['email'];
  10. if (empty($email))
  11. {
  12. $field="vous devez indiquer votre mail !";
  13.  if (empty($userfile) && empty($userfile2) && empty($userfile3) && empty($userfile4) && empty($userfile5))
  14.  {
  15.  $field="vous devez choisir au moins un fichier !";
  16.  }
  17.  else
  18.  {
  19.  $uploaddir = 'clients/'.$batnum.'/';
  20.  mkdir($uploaddir,0777);
  21.  //fichier1
  22.   if (!empty($userfile))
  23.   {
  24.   if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir.$_FILES['userfile']['name']))
  25.   {
  26.   $file_name=str_replace(" ", "_",$_FILES['userfile']['name']);
  27.   rename ($uploaddir.$_FILES['userfile']['name'],$uploaddir.$file_name);
  28.   $_FILES['userfile']['name']=$file_name;
  29.   $type=$_FILES['userfile']['type'];
  30.   $file_in=$_FILES['userfile']['name'];
  31.   $file_out="xxxxxxx.pdf";
  32.   }
  33.   }
  34.  // fichier 2  
  35.   if (!empty($userfile2))
  36.   {
  37.   if (move_uploaded_file($_FILES['userfile2']['tmp_name'], $uploaddir.$_FILES['userfile2']['name']))
  38.   {
  39.   $file_name2=str_replace(" ", "_",$_FILES['userfile2']['name']);
  40.   rename ($uploaddir.$_FILES['userfile2']['name'],$uploaddir.$file_name2);
  41.   $_FILES['userfile2']['name']=$file_name2;
  42.   $type2=$_FILES['userfile2']['type'];
  43.   $file_in2=$_FILES['userfile2']['name'];
  44.   $file_out2="xxxxxxx.pdf";
  45.   }
  46.   }
  47.  // fichier 3  
  48.   if (!empty($userfile3))
  49.   {
  50.   if (move_uploaded_file($_FILES['userfile3']['tmp_name'], $uploaddir.$_FILES['userfile3']['name']))
  51.   {
  52.   $file_name3=str_replace(" ", "_",$_FILES['userfile3']['name']);
  53.   rename ($uploaddir.$_FILES['userfile3']['name'],$uploaddir.$file_name3);
  54.   $_FILES['userfile3']['name']=$file_name3;
  55.   $type3=$_FILES['userfile3']['type'];
  56.   $file_in3=$_FILES['userfile3']['name'];
  57.   $file_out3="xxxxxxx.pdf";
  58.   }
  59.   }
  60.  // fichier 4  
  61.   if (!empty($userfile4))
  62.   {
  63.   if (move_uploaded_file($_FILES['userfile4']['tmp_name'], $uploaddir.$_FILES['userfile4']['name']))
  64.   {
  65.   $file_name4=str_replace(" ", "_",$_FILES['userfile4']['name']);
  66.   rename ($uploaddir.$_FILES['userfile4']['name'],$uploaddir.$file_name4);
  67.   $_FILES['userfile4']['name']=$file_name4;
  68.   $type4=$_FILES['userfile4']['type'];
  69.   $file_in4=$_FILES['userfile4']['name'];
  70.   $file_out4="xxxxxxx.pdf";
  71.   }
  72.   }
  73.  // fichier 5  
  74.   if (!empty($userfile5))
  75.   {
  76.   if (move_uploaded_file($_FILES['userfile5']['tmp_name'], $uploaddir.$_FILES['userfile5']['name']))
  77.   {
  78.   $file_name5=str_replace(" ", "_",$_FILES['userfile5']['name']);
  79.   rename ($uploaddir.$_FILES['userfile4']['name'],$uploaddir.$file_name5);
  80.   $_FILES['userfile5']['name']=$file_name5;
  81.   echo $type5=$_FILES['userfile5']['type'];
  82.   $file_in5=$_FILES['userfile5']['name'];
  83.   $file_out5="xxxxxxx.pdf";
  84.   }
  85.   }
  86.  }
  87.  if ($_FILES['userfile'] || $_FILES['userfile2'] || $_FILES['userfile3'] || $_FILES['userfile4'] || $_FILES['userfile5'])
  88.  {
  89.  //parametres
  90.  $path=$uploaddir;
  91.  $date=date("d/m/Y" );
  92.  $newold="NEW";
  93.  $validation="COU";
  94.  mysql_select_db("$bddname", $connect);
  95.  $sql="INSERT INTO bat1 (id, batnum, type, type2, type3, type4, type5, path, file_in, file_in2, file_in3, file_in4, file_in5, file_out , file_out2 ,file_out3 ,file_out4 ,file_out5 ,mailbat, date, newold, validation)";
  96.  $sql.=" VALUES ('$id_test','$batnum', '$type','$type2','$type3','$type4','$type5','$path','$file_in','$file_in2','$file_in3','$file_in4','$file_in5','$file_out', '$file_out2', '$file_out3', '$file_out4', '$file_out5', '$email','$date', '$newold', '$validation')";
  97.  mysql_query("$sql" );
  98.  echo mysql_error() ;
  99.  }
  100. }
  101. }


 
Thx !!!

Reply

Marsh Posté le 29-01-2004 à 11:35:56   

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed