This following tip will show you how to upload multiple files, rename the files while uploading based on the auto-increment ID field, and then display the files vertically (multi-line) instead of horizontally (one-line) in Delete, List, and View pages.**1. Create a MySQL table named upload_files using the following SQL script:
CREATE TABLE `upload_file` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`File_Name` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`Date_Uploaded` datetime NOT NULL,
PRIMARY KEY (`ID`) USING BTREE
) ENGINE = MyISAM AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
**2. Create a new fresh project and connect to that database and table above.**3. Go to Fields setup, select File_Name field, choose File, and then enable Multiple from Edit Tag pane → File Upload.**4. Insert the following code into Row_Inserting server event, so the complete code as follows:
// Row Inserting event
function Row_Inserting($rsold, &$rsnew)
{
// Enter your code here
// To cancel, set return value to false
$NewFiles = explode(Config("MULTIPLE_UPLOAD_SEPARATOR"), $rsnew["File_Name"]);
$NextID = ExecuteScalar("SELECT COALESCE(MAX(ID),0) +1 CNT FROM upload_file") ;
$FileCount = count($NewFiles);
if (trim($NewFiles[0]) == '') return true; // skip if no file uploaded
for ($i = 0; $i < $FileCount; $i++) {
if (trim($NewFiles[$i]) != '') {
$files = $NewFiles[$i];
$file_extension = substr(strtolower(strrchr($files, ".")), 1);
$files = $NextID. "-" .date("YmdHis", strtotime($rsnew['Date_Uploaded'])). "-" . ($i + 1) . "." . $file_extension;
$NewFiles[$i] = $files;
}
}
$sFileName = implode(Config("MULTIPLE_UPLOAD_SEPARATOR"), $NewFiles);
$rsnew['File_Name'] = $sFileName;
return true;
}
**5. Put the following code into Startup Script section of **Delete Page, List Page, and also View Page:
$('div.d-flex.flex-row.ew-images').removeClass('flex-row').addClass('flex-column');
If you want to reverse the order of File_Name, then simply change flex-column to flex-column-reverse.**6. Generate ALL the script files, and enjoy the final result from the generated web application via your favorite browser.