I am working on my project I want to upload images with single form but I have two input fields. I want when I choose the both images on both input fields when I submit it I want my both files are stored in the folder I show you my code but with this code, I am getting only one image. I want both images which I am uploaded. my form looks like this
Here is my code: public function upload_creative_workshop_image($post, $files){ //print_r($files); die; $allowedExts= array("jpeg", "jpg", "png", "gif"); $temp = explode(".", $files["image1"]["name"]); $extension = end($temp); if ((($files["image1"]["type"] == "image/jpeg") //check image is mp3 || ($files["image1"]["type"] == "image/gif") //check image is mp4 || ($files["image1"]["type"] == "image/jpg") //check image is jpg || ($files["image1"]["type"] == "image/png")) //check image is png && ($files["image1"]["size"]) //check if image size is below 6MB && in_array(trim($extension), $allowedExts)) //check the extensions also { if($files["image1"]["error"] > 0){ echo $files["image1"]["error"]; } else{ $filename = $files["image1"]["name"]; $upload= move_uploaded_file($files["image1"]["tmp_name"], $this->img_path.$filename); //print_r($upload); die; if($upload){ //$this->store_image_indb($filename, $post); } } }else{ echo "<h1>please upload image only</h1>"; } } 
image1andimage2. BUT what I would do is to make your input field multiple and then call your function once with the images in$filesarray. For that you have to add a loop into your function.var_dump($_FILES)?