多张图片上传有问题?附加数据库图像
Having issue in multiple image upload? db image attached
<form name="property" action="" method="post" enctype="multipart/form-data">
Select Image
<input type="file" name="upload[]" multiple="multiple" id="image"/>
<input type="submit" value="Submit" name="submit" style="width:200px; height:30px;" />
</form>
我的Php代码:
if(isset($_POST['submit']))
{
$total = count($_FILES['upload']['name']);
for($i=0; $i<$total; $i++)
{
$tmpFilePath = $_FILES['upload']['tmp_name'][$i];
if ($tmpFilePath != "")
{
$newFilePath[] = "upload/" . $_FILES['upload']['name'][$i];
$values_insert = implode(',', $newFilePath);
if(move_uploaded_file($tmpFilePath, $newFilePath))
{
$date=date("Y-m-d");
}
}
}
$d=mysql_query("INSERT INTO properties (iname,cdate) VALUES('".$values_insert."',NOW())") or die(mysql_error());
}
注:
在数据库中,路径上传目录文件夹和图像图像将进入数据库,我只想要用逗号分隔的图像名称。例如,预期输出为 Chrysanthemum.jpg、Desert.jpg。我不知道是什么问题。请指导me.kindly查看我的代码和图片附件详细信息。
仅供参考 - 缩进代码有助于人们阅读和帮助您。
if(isset($_POST['submit']))
{
$total = count($_FILES['upload']['name']);
for($i=0; $i<$total; $i++)
{
$tmpFilePath = $_FILES['upload']['tmp_name'][$i];
if ($tmpFilePath != "")
{
$newFilePath = "upload/" . $_FILES['upload']['name'][$i];
$newFilePath2[] = $_FILES['upload']['name'][$i];
$values_insert = implode(',', $newFilePath2);
if(move_uploaded_file($tmpFilePath, $newFilePath))
{
$date=date("Y-m-d");
}
}
}
$d=mysql_query("INSERT INTO properties (iname,cdate) VALUES('".$values_insert."',NOW())") or die(mysql_error());
}
<form name="property" action="" method="post" enctype="multipart/form-data">
Select Image
<input type="file" name="upload[]" multiple="multiple" id="image"/>
<input type="submit" value="Submit" name="submit" style="width:200px; height:30px;" />
</form>
我的Php代码:
if(isset($_POST['submit']))
{
$total = count($_FILES['upload']['name']);
for($i=0; $i<$total; $i++)
{
$tmpFilePath = $_FILES['upload']['tmp_name'][$i];
if ($tmpFilePath != "")
{
$newFilePath[] = "upload/" . $_FILES['upload']['name'][$i];
$values_insert = implode(',', $newFilePath);
if(move_uploaded_file($tmpFilePath, $newFilePath))
{
$date=date("Y-m-d");
}
}
}
$d=mysql_query("INSERT INTO properties (iname,cdate) VALUES('".$values_insert."',NOW())") or die(mysql_error());
}
注:
在数据库中,路径上传目录文件夹和图像图像将进入数据库,我只想要用逗号分隔的图像名称。例如,预期输出为 Chrysanthemum.jpg、Desert.jpg。我不知道是什么问题。请指导me.kindly查看我的代码和图片附件详细信息。
仅供参考 - 缩进代码有助于人们阅读和帮助您。
if(isset($_POST['submit']))
{
$total = count($_FILES['upload']['name']);
for($i=0; $i<$total; $i++)
{
$tmpFilePath = $_FILES['upload']['tmp_name'][$i];
if ($tmpFilePath != "")
{
$newFilePath = "upload/" . $_FILES['upload']['name'][$i];
$newFilePath2[] = $_FILES['upload']['name'][$i];
$values_insert = implode(',', $newFilePath2);
if(move_uploaded_file($tmpFilePath, $newFilePath))
{
$date=date("Y-m-d");
}
}
}
$d=mysql_query("INSERT INTO properties (iname,cdate) VALUES('".$values_insert."',NOW())") or die(mysql_error());
}