if(isset($_POST['btnSave'])){
$j = 0; //Variable for indexing uploaded image
$file_name_all="";
$target_path = "uploads/"; //Declaring Path for uploaded images
//loop to get individual element from the array
for ($i = 0; $i < count($_FILES['file']['name']); $i++) {
$validextensions = array("jpeg", "jpg", "png"); //Extensions which are allowed
$ext = explode('.', basename($_FILES['file']['name'][$i]));//explode file name from dot(.)
$file_extension = end($ext); //store extensions in the variable
$basename=basename($_FILES['file']['name'][$i]);
//echo"hi its base name".$basename;
$target_path = $target_path .$basename;//set the target path with a new name of image
$j = $j + 1;//increment the number of uploaded images according to the files in array
if (($_FILES["file"]["size"][$i] < (1024*1024)) //Approx. 100kb files can be uploaded.
&& in_array($file_extension, $validextensions)) {
if (move_uploaded_file($_FILES['file']['tmp_name'][$i], $target_path)) {//if file moved to uploads folder
echo $j. ').Image uploaded successfully!.
';
/***********************************************/
$file_name_all.=$target_path."*";
$filepath = rtrim($file_name_all, '*');
//echo"";
/*************************************************/
} else {//if file was not moved.
echo $j. ').please try again!.
';
}
} else {//if file size and file type was incorrect.
echo $j. ').***Invalid file Size or Type***
';
}
}
$qry="INSERT INTO `eb_re_about_us`(`er_abt_us_id`, `er_cli_id`, `er_cli_abt_info`, `er_cli_abt_img`) VALUES (NULL,'$b1','$b5','$filepath')";
$res = mysql_query($qry,$conn);
if($res)
echo "
Client contact Person Information Details Saved successfully";
//header("location: nextaddclient.php");
//exit();
else
echo "
Client contact Person Information Details not saved successfully";
}
?>
在这里 $ file_name_all和$ filepath获得1个上层文件名2次?