class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
I'm trying to allow HTML files to be uploaded, and I've added a check to ensure that only HTML files are uploaded.
But every time I upload one, it is getting the .txt extension added. I've tried setting no_script to false, but when I do this I then get an 'Incorrect file type' error for any file that I try to upload.
But every time I upload one, it is getting the .txt extension added. I've tried setting no_script to false, but when I do this I then get an 'Incorrect file type' error for any file that I try to upload.
Here's the code;
$newmenu = new upload($_FILES['menu_file']); if ($newmenu->uploaded) { if ($newmenu->file_src_mime != 'text/html') { die('Error: Error Message' . $newmenu->clean()); } else { $newmenu->file_auto_rename = false; $newmenu->file_safe_name = true; $newmenu->file_overwrite = true; $newmenu->no_script = false; $newmenu->process('../menus/'); if ($newmenu->processed) { echo 'File Uploaded'; } else { echo 'error : ' . $newmenu->error; } } }Or, if you want to only allow HTML files:
$newmenu->no_script = false; $newmenu->allowed = array('text/html');