php写一个表单上传一张图片,一键输入多个图像上传PHP表单

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".%24filepath.";

/*************************************************/

} 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次?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值