php批量上传的实现代码
编程学习 2021-07-05 09:49www.dzhlxh.cn编程入门
本篇文章是对php批量上传的实现代码进行了详细的分析介绍,需要的朋友参考下
如下所示:
if (isset($_POST['submit'])) {
foreach($_FILES['product_img']['error'] as $k=>$v){
if ($v == UPLOAD_ERR_OK) {
$sql ='product_img'.($k+1);
$tmp_name = $_FILES['product_img']['tmp_name'][$k];
$file_name = $_FILES['product_img']['name'][$k];
$file_type = $_FILES['product_img']['type'][$k];
$upload_name = getPath('../Public/Upload').time().'_'.$file_name;
@move_uploaded_file($tmp_name,$upload_name);
$map[$sql] = $file_name;
print_r($map);
exit;
}
}
}
代码如下:
if (isset($_POST['submit'])) {
foreach($_FILES['product_img']['error'] as $k=>$v){
if ($v == UPLOAD_ERR_OK) {
$sql ='product_img'.($k+1);
$tmp_name = $_FILES['product_img']['tmp_name'][$k];
$file_name = $_FILES['product_img']['name'][$k];
$file_type = $_FILES['product_img']['type'][$k];
$upload_name = getPath('../Public/Upload').time().'_'.$file_name;
@move_uploaded_file($tmp_name,$upload_name);
$map[$sql] = $file_name;
print_r($map);
exit;
}
}
}
上一篇:PHP版 汉字转码的实现详解
下一篇:PHP转换IP地址到真实地址的方法详解