将多个图像字段上传到服务器mysql中的每一行


Uploading multiple image fields to each row in server mysql

在我的帖子页面中,我有多个上传字段。

    <form action="" method="post" enctype="multipart/form-data"
    class="form-horizontal">
    <div class="form-group col-md-5">
    <label for="image">Big pic</label>
    <input id="image" type="file" name="image" class="btn btn-danger">
     </div>
     <div class="form-group col-md-5">
     <label for="img_v1">V1</label>
     <input id="img_v1" type="file" name="img_v1" class="btn btn-danger">
     </div>
     <div class="form-group col-md-5">
    <label for="img_v2">V2</label>
    <input id="img_v2" type="file" name="img_v2" class="btn btn-danger">
    </div>

我想把每个字段上传到我的服务器中的每一行。

我的上传脚本在同一个文件中。

$error = ''; 
if(isset($_POST['submit_post'])){
$title = strip_tags($_POST['title']);
$date = date('Y-m-d h:i:s');
if($_FILES['image']['name'] !=''){
$image_name = $_FILES['image']['name']; 
$image_tmp = $_FILES['image']['tmp_name'];
$image_size = $_FILES['image']['size'];
$image_ext = pathinfo($image_name,PATHINFO_EXTENSION);
$image_path = '../clientes/img/'.$image_name;
$image_db_path = 'img/'.$image_name;
if($image_size < 10000000){
if($image_ext == 'jpg' || $image_ext == 'png' || $image_ext == 'jpeg' ||       $image_ext == 'gif'){
if(move_uploaded_file($image_tmp,$image_path)){
$ins_sql = "INSERT INTO gallery (title, description, image, category,   status) VALUES ('$title', '$_POST[description]',
 '$image_db_path', '$_POST[category]', '$_POST[status]')";
  if(mysqli_query($conn,$ins_sql)){
  header('post_list.php');
 }else{
  $error = '<div class="alert alert-danger">Erro de script</div>';
  }
  }else{
  '<div class="alert alert-danger">Image cant upload</div>';
  } 
  }else{
  $error = '<div class="alert alert-danger">Wrong image extention</div>';
  }
  }else{
  $error = '<div class="alert alert-danger">Image is to much big</div>';
  }
  }else{
  $ins_sql = "INSERT INTO gallery (title, description, category, status,     date, author) VALUES ('$title', '$_POST[description]', 
  '$_POST[category]', '$_POST[status]', '$date', '$_SESSION[userName]    $_SESSION[userLName]')";
  if(mysqli_query($conn,$ins_sql)){
  header('post_list.php');
  }else{
  $error = '<div class="alert alert-danger">Script error</div>';
  }
  }
  }

我试着像这样把3个字段上传到服务器上。。。

插入库(标题、说明、图像、img_v1、img_v2类别、状态)值('$title'、'$_POST[description]','$image_db_path'、'$image_db_path','$image.db_path'、'$_POST[category]'、'$S_POST[status]')";

但我知道这是错误的。我必须做什么才能上传额外的img字段?

img_v2和category之间缺少一个逗号。

INSERT INTO gallery (title, description, image,img_v1, img_v2, category, status) VALUES ('$title', '$_POST[description]', '$image_db_path','$image_db_path','$image_db_path', '$_POST[category]', '$_POST[status]')";