我有一个用 php 上传的多个文件,我想为每个上传的文件创建插入一个 mysql 行。例如,如果上传了 3 个文件:a.txt、b.txt 和 c.txt,它将创建 3 个插入查询,其中 $filename 是 a.txt,第二个是 b.txt,第三个是 3.txt。这可能吗?
$target = "test/";
if($target[strlen($target)-1]!='/')
$target=$target.'/';
$count=0;
foreach ($_FILES['uploaded']['name'] as $filename)
{
$temp=$target;
$tmp=$_FILES['uploaded']['tmp_name'][$count];
$count=$count + 1;
$temp=$temp.basename($filename);
move_uploaded_file($tmp,$temp);
$temp='';
$tmp='';
}
//for each file uploaded mysql_query("INSERT INTO files VALUES('','$date','$filename')");