$val) { $image_name = $_FILES['images']['name'][$key]; $tmp_name = $_FILES['images']['tmp_name'][$key]; $size = $_FILES['images']['size'][$key]; $type = $_FILES['images']['type'][$key]; $error = $_FILES['images']['error'][$key]; // File upload path $code = time(); $fileName = basename($_FILES['images']['name'][$key]); $fileName = $idtrf . '-' . $code . $fileName; $targetFilePath = $targetDir . $fileName; // Check whether file type is valid $fileType = strtolower(pathinfo($targetFilePath, PATHINFO_EXTENSION)); if (in_array($fileType, $allowTypes)) { // Store images on the server if (move_uploaded_file($_FILES['images']['tmp_name'][$key], $targetFilePath)) { $images_arr[] = $targetFilePath; $UpdateQuery = new WA_MySQLi_Query($cmctrfdb); $UpdateQuery->Action = "update"; $UpdateQuery->Table = "`trf-details`"; $UpdateQuery->bindColumn("photofilename", "s", "$fileName", "WA_DEFAULT"); $UpdateQuery->addFilter("idtrfdetails", "=", "i", "" . ($idtrf) . ""); $UpdateQuery->execute(); $UpdateGoTo = ""; $UpdateQuery->redirect($UpdateGoTo); } } } // Generate gallery view of the images if (!empty($images_arr)) { ?>