Php 在表单中使用1个字段发布多个图像

Php 在表单中使用1个字段发布多个图像,php,wordpress,Php,Wordpress,我的代码在这里。如何使用一个输入字段上载一个以上的图像 <?php if (isset($_POST['beopen_form'])) { if ($_FILES["file1"]["error"] > 0) { echo "Error: " . $_FILES["file1"]["error"] . "<br>"; } else { $x = mysql_insert_id(); $path_array = wp_upload_

我的代码在这里。如何使用一个输入字段上载一个以上的图像

<?php
if (isset($_POST['beopen_form'])) {
if ($_FILES["file1"]["error"] > 0) {
    echo "Error: " . $_FILES["file1"]["error"] . "<br>";
} else {
    $x          = mysql_insert_id();
    $path_array = wp_upload_dir();
    $old_name   = $_FILES["file1"]["name"];
    $split_name = explode('.', $old_name);
    $time       = time();
    $file_name  = $time . "." . $split_name[1];
    $tmp_name   = $_FILES["file1"]["tmp_name"];
    move_uploaded_file($_FILES["file"]["tmp_name"], $path . "/" . $old_name);
    $path2 = $path . "/" . $old_name;
    mysql_query("INSERT INTO carimage (image,carid,created,updated) VALUES ('$path2','$x','$created','$updated') ON DUPLICATE KEY UPDATE image='$path2',description='$makeid',updated='$updated'");
}
}
?>
<form enctype="multipart/form-data" class="beopen-contact-form" id="signupForm" novalidate="novalidate" action="<?php echo get_permalink(); ?>" method="post"> 
    <input type="file" name="file" id="file">
    <div id="recaptcha_div"></div><br>
    <input type="hidden" name="beopen_form" value="1" /><!-- button  -->
    <button class="button send-message" type="submit">
        <span class="send-message"></span><?php _e('Update', 'beopen');?>
    </button>    
</form>
html:-

<input type="file" name="file" id="file" multiple>

PHP代码:-

//Loop through each file
for($i=0; $i<count($_FILES['file']['name']); $i++) {
  //Get the temp file path
  $tmpFilePath = $_FILES['file']['tmp_name'][$i];

  //Make sure we have a filepath
  if ($tmpFilePath != ""){
    //Setup our new file path
    $newFilePath = "./uploadFiles/" . $_FILES['file']['name'][$i];

    //Upload the file into the temp dir
    if(move_uploaded_file($tmpFilePath, $newFilePath)) {

      //Handle other code here

    }
  }
}
//遍历每个文件

对于($i=0;$iI)已搜索。但我想像这样使用此文件