Php 多个图像上传代替多个文件字段 这是普通文本

Php 多个图像上传代替多个文件字段 这是普通文本,php,mysql,Php,Mysql,这也是,但现在遵循一个代码块: 对于文件上传,我使用下面的代码,但我会在数据库中得到三个输入相同的图像 对于文件上传,我使用下面的代码,但我会在数据库中得到三个输入相同的图像 对于文件上传,我使用下面的代码,但我会在数据库中得到三个输入相同的图像 <?php include('includes/config.php'); if(isset($_POST['submit'])) { $file = $_FILES['mulkia1']['name']; $file_loc = $_

这也是,但现在遵循一个代码块: 对于文件上传,我使用下面的代码,但我会在数据库中得到三个输入相同的图像 对于文件上传,我使用下面的代码,但我会在数据库中得到三个输入相同的图像 对于文件上传,我使用下面的代码,但我会在数据库中得到三个输入相同的图像

<?php
include('includes/config.php');
if(isset($_POST['submit']))
{

  $file = $_FILES['mulkia1']['name'];
  $file_loc = $_FILES['mulkia1']['tmp_name'];
  $folder="images/"; 
  $new_file_name = strtolower($file);
  $final_file=str_replace(' ','-',$new_file_name);

  $file1 = $_FILES['frontcar1']['name'];
  $file_loc1 = $_FILES['frontcar1']['tmp_name'];
  $folder1="images/imag"; 
  $new_file_name1  = strtolower($file1);
  $final_file1=str_replace(' ','-',$new_file_name1);

  $file2 = $_FILES['backcar1']['name'];
  $file_loc2 = $_FILES['backcar1']['tmp_name'];
  $folder1="images/img"; 
  $new_file_name2  = strtolower($file2);
  $final_file2=str_replace(' ','-',$new_file_name2);

  $coupon=$_POST['coupon'];
  $mobileno=$_POST['mobileno'];
  $email=$_POST['email'];

if(move_uploaded_file($file_loc,$folder.$final_file))
   {
   $mulkia1=$final_file;

    }
    if(move_uploaded_file($file_loc1,$folder1.$final_file1))
    {
      $frontcar1=$final_file1;

      }
      if(move_uploaded_file($file_loc2,$folder.$final_file2))
    {
      $backcar1=$final_file2;

      }

$notitype='Create Account';
$reciver='Admin';
$sender=$email;

$sqlnoti="insert into notification (notiuser,notireciver,notitype) 
values (:notiuser,:notireciver,:notitype)";
$querynoti = $dbh->prepare($sqlnoti);
$querynoti-> bindParam(':notiuser', $sender, PDO::PARAM_STR);
$querynoti-> bindParam(':notireciver',$reciver, PDO::PARAM_STR);
$querynoti-> bindParam(':notitype', $notitype, PDO::PARAM_STR);
$querynoti->execute();    

 $sql ="INSERT INTO 
users(coupon,mobile,email,mulkia1,frontcar1,backcar1) 
VALUES(:coupon, :mobileno, :email, :mulkia1, :frontcar1, :backcar1)";
$query= $dbh -> prepare($sql);
$query-> bindParam(':coupon', $coupon, PDO::PARAM_STR);
$query-> bindParam(':mobileno', $mobileno, PDO::PARAM_STR);
$query-> bindParam(':email', $email, PDO::PARAM_STR);
$query-> bindParam(':mulkia1', $mulkia1, PDO::PARAM_STR);
$query-> bindParam(':frontcar1', $mulkia1, PDO::PARAM_STR);
$query-> bindParam(':backcar1', $mulkia1, PDO::PARAM_STR);
$query->execute();
$lastInsertId = $dbh->lastInsertId();
if($lastInsertId)
{
echo "<script type='text/javascript'>alert('Registration Sucessfull!');</script>";

}
else 
{
 $error="Something went wrong. Please try again";
 }

 }
 ?>    

a至少if(move_upload_file($file_loc2,$folder.$final_file2))应该是if(move_upload_file($file_loc2,$folder1.$final_file2))但是你确定文件1-2是不同的吗?你回显了文件名吗?是的,我回显了不同的结果,我得到了解决方案,我调用了相同的id,原因是相同的图像插入任何一个帮助我这段代码有时有效,有时无效