php批量上传的实现代码
程序员文章站
2022-07-11 08:53:59
如下所示:复制代码 代码如下: if (isset($_post['submit'])) { foreach($_f...
如下所示:
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;
}
}
}