我有一个用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')");
答案 0 :(得分:2)
答案 1 :(得分:0)
肯定有可能。只需在foreach块的末尾添加mysql_query即可。