pallets-eco / flask-admin

Simple and extensible administrative interface framework for Flask
https://flask-admin.readthedocs.io
BSD 3-Clause "New" or "Revised" License
5.7k stars 1.56k forks source link

File-Admin editable_extensions HTML Editor ? #1873

Open bekab95 opened 5 years ago

bekab95 commented 5 years ago

Can editable_extensions allowed files be overridden with html editor when editing file ?

ljluestc commented 2 weeks ago

<?php
// Assuming $_FILES['file'] is the file input name from your HTML form

$allowed_extensions = array('pdf', 'doc', 'docx', 'txt'); // Allowed extensions

$upload_file = $_FILES['file']['name'];
$file_extension = pathinfo($upload_file, PATHINFO_EXTENSION); // Get file extension

if (in_array($file_extension, $allowed_extensions)) {
    // Valid file type, proceed with upload or other operations
    move_uploaded_file($_FILES['file']['tmp_name'], 'uploads/' . $_FILES['file']['name']);
    echo 'File uploaded successfully.';
} else {
    // Invalid file type, handle error
    echo 'Error: Invalid file type. Allowed file types are: ' . implode(', ', $allowed_extensions);
}
?>