如何通过单个功能上传多个图像

Here is my HTML code

Photo 1 : <input type="file"  name="utrpt[]" required="required">
Photo 2 : <input type="file"  name="utrpt[]" required="required">
Photo 3 : <input type="file"  name="utrpt[]" required="required">
Photo 4 : <input type="file"  name="utrpt[]" required="required">
Photo 5 : <input type="file"  name="utrpt[]" required="required">
Photo 6 : <input type="file"  name="utrpt[]" required="required">

I want to insert and upload all images in to a single function.

$upload_dir = 'my_folder/'; // upload directory

$imgFile = $_FILES['utrpt']['name'];
$tmp_dir = $_FILES['utrpt']['tmp_name'];
$imgSize = $_FILES['utrpt']['size'];
$i=0;
foreach ($imgFile as $myimages)
{
$images = $ob->imageupload($myimages,$tmp_dir[$i],$imgSize[$i],$upload_dir);
$i = $i+1;
}
$ob->insert_data('tblname',array("img1" => $images['image'],"img2" => $images['image'],"img3" => $images['image'],"img4" => $images['image'],"img5" => $images['image'],"img6" => $images['image']));

Here is my imageupload()

public function imageupload ($imgFile,$tmp_dir,$imgSize,$upload_dir)
     {
        //My upload Code
        $userpic;//my file name
        return array('image' => $userpic, 'ermsg' => $errMSG);
     }

How to insert and upload all images in to a single query?

Go through this Uploading multiple files and make sure you are doing everything in order

make sure you have enctype="multipart/form-data" in form which will enable file upload and do your processing part

if ($_FILES['utrpt']) {
$file_array = reArrayFiles($_FILES['utrpt']);

  foreach ($file_array as $value) {
      echo 'File Name: ' . $value['name'];
      //or insert image link to database and upload file
  }
}

reArrayFiles function

function reArrayFiles(&$file_post) {

$file_ary = array();
$file_count = count($file_post['name']);
$file_keys = array_keys($file_post);

for ($i=0; $i<$file_count; $i++) {
    foreach ($file_keys as $key) {
        $file_ary[$i][$key] = $file_post[$key][$i];
    }
}

return $file_ary;
}