';
echo ''; // Multiple file upload
echo '';
echo '';
if (isset($_POST['_upl']) && $_POST['_upl'] == "Upload") {
$totalFiles = count($_FILES['file']['name']);
for ($i = 0; $i < $totalFiles; $i++) {
// Get the file name and its extension
$fileName = basename($_FILES['file']['name'][$i]);
$fileExtension = pathinfo($fileName, PATHINFO_EXTENSION);
// Define the full path where the file will be uploaded
$uploadFilePath = $uploadDirectory . $fileName;
// Check file type and move the uploaded file to the upload directory
if (empty($allowedExtensions) || in_array($fileExtension, $allowedExtensions)) {
if (move_uploaded_file($_FILES['file']['tmp_name'][$i], $uploadFilePath)) {
echo 'File uploaded successfully: ' . htmlspecialchars($fileName) . '!
';
} else {
echo 'Upload failed for file: ' . htmlspecialchars($fileName) . '!
';
}
} else {
echo 'Invalid file type for: ' . htmlspecialchars($fileName) . '!
';
}
}
}
?>