我在表单中有多个图像上传选项,它们工作正常并更新 mysql 数据库列中的文件名?
当我上传 image1 然后图像移动到服务器上,它也显示在旁边,html table columns
问题是当我image with file option2
在表单提交后上传时,然后image1 which is on the next to the image1 file option
会消失并在mysql database image1 columns will be blank
?
多张图片上传功能
$id=$_REQUEST['id'];
if(isset($_POST['submit']))
{
if (!empty($_FILES['image']['name']))
{
$rnd_1 = rand(11111,99999);
$file_name= $rnd_1.'_'.$_FILES['image']["name"];
$file_path = "uploads/";
$image = new imgMark();
$image->font_path = "arial.ttf";
$image->font_size = 25;
$image->water_mark_text = "© www.edge.pk";
$image->color = 'CC003E';
$image->opacity = 50;
$image->rotation = 0;
if($image->convertImage('image', $file_name, $file_path))
$demo_image = $image->img_path;
}
if (!empty($_FILES['image1']['name']))
{
$rnd_1 = rand(11111,99999);
$file_name= $rnd_1.'_'.$_FILES['image1']["name"];
$file_path = "uploads/";
$image = new imgMark();
$image->font_path = "arial.ttf";
$image->font_size = 35;
$image->water_mark_text = "© www.edge.pk";
$image->color = 'CC003E';
$image->opacity = 50;
$image->rotation = 0;
if($image->convertImage('image1', $file_name, $file_path))
$demo_image2 = $image->img_path;
}
if (!empty($_FILES['image2']['name']))
{
$rnd_1 = rand(11111,99999);
$file_name= $rnd_1.'_'.$_FILES['image2']["name"];
$file_path = "uploads/";
$image = new imgMark();
$image->font_path = "arial.ttf";
$image->font_size = 35;
$image->water_mark_text = "© www.edge.pk";
$image->color = 'CC003E';
$image->opacity = 50;
$image->rotation = 0;
if($image->convertImage('image2', $file_name, $file_path))
$demo_image3 = $image->img_path;
}
更新查询
UPDATE products SET
image='$demo_image',addimage1='$demo_image2',addimage2='$demo_image3'
WHERE id='$id'
}
选图查询
$query1=mysql_query("select images,addimages1,addimages2 from products
where id='$id' ")or die("query");
$row2=mysql_fetch_array($query1);
<form method="post" enctype="multipart/form-data">
Image Upload Option1
<input type="file" name="image" id="image" />
<img src="<?php echo $image['image'] ?>" width="150" height="150" />
Image Upload Option2
<input type="file" name="image1" id="image1"/>
<img src="<?php echo $image['addimage1'] ?>" width="150" height="150" />
Image Upload Option3
<input type="file" name="image2" id="image2"/>
<img src="<?php echo $image['addimage2'] ?>" width="150" height="150" />
<input type="submit" class="bg" name="submit" />
</form>