$val){ $doc_name = $_FILES['doc']['name'][$key]; $tmp_name = $_FILES['doc']['tmp_name'][$key]; $size = $_FILES['doc']['size'][$key]; $type = $_FILES['doc']['type'][$key]; $error = $_FILES['doc']['error'][$key]; // File upload path $code=time(); $fileName = basename($_FILES['doc']['name'][$key]); $fileName=$idtrf.'-'.$code.$fileName; $targetFilePath = $targetDir . $fileName; // Check whether file type is valid $fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION); if(in_array($fileType, $allowTypes)){ // Store images on the server if(move_uploaded_file($_FILES['doc']['tmp_name'][$key],$targetFilePath)){ $docs_arr[] = $targetFilePath; $InsertQuery = new WA_MySQLi_Query($cmctrfdb); $InsertQuery->Action = "insert"; $InsertQuery->Table = "fileattached"; $InsertQuery->bindColumn("idtrfdetails", "i", "$idtrf", "WA_DEFAULT"); $InsertQuery->bindColumn("filename_fileattached", "s", "$fileName", "WA_DEFAULT"); $InsertQuery->bindColumn("description_fileattached", "s", "$filedescription", "WA_DEFAULT"); $InsertQuery->saveInSession(""); $InsertQuery->execute(); $InsertGoTo = ""; $InsertQuery->redirect($InsertGoTo); } } } // Generate gallery view of the images /*if(!empty($docs_arr)){ ?> setQuery("SELECT * FROM fileattached WHERE fileattached.idtrfdetails='$idtrf'"); $filenamelist->execute(); while(!$filenamelist->atEnd()) { $wa_startindex = $filenamelist->Index; ?> " target="_blank"> getColumnVal("description_fileattached")); ?> "> moveNext(); } } ?>