Re: Secure File Upload Class - Problem
Posted: Sun Jul 24, 2011 3:29 pm
Hi, sorry to bug you again, but I am having a little problem.
Everythings works perfectly except the file max size, basicaly if the file size is superior to the one set, it won't return an error, wont upload either of course, but it just returns to the upload page with all forms reset :/
Thanks for your time.
Everythings works perfectly except the file max size, basicaly if the file size is superior to the one set, it won't return an error, wont upload either of course, but it just returns to the upload page with all forms reset :/
<?php error_reporting(E_ALL & ~E_STRICT); include('mime_content_type.php'); include('secure_upload.class.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Secure File Upload Class</title> </head> <body> <?php if (isset($_FILES['file1'])){ $upload1 = new secure_upload('file1'); $upload1->set_max_size(1310720); $upload1->set_extension_whitelist(array('zip','rar','doc','docx','pdf')); $upload1->save_to('./files/' . $upload1->name); if ($upload1->error > 0){ echo '<div>Error: ', $upload1->get_error_constant_name(), '</div>'; }else{ echo 'success'; } } if (isset($_FILES['file2'])){ $upload2 = new secure_upload('file2'); $upload2->set_max_size(1310720); $upload2->set_extension_whitelist(array('zip','rar','doc','docx','pdf')); $upload2->save_to('./files/' . $upload2->name); if ($upload2->error > 0){ echo '<div>Error: ', $upload2->get_error_constant_name(), '</div>'; }else{ //echo 'success'; } } if (isset($_FILES['file3'])){ $upload3 = new secure_upload('file3'); $upload3->set_max_size(1310720); $upload3->set_extension_whitelist(array('zip','rar','doc','docx','pdf')); $upload3->save_to('./files/' . $upload3->name); if ($upload3->error > 0){ echo '<div>Error: ', $upload3->get_error_constant_name(), '</div>'; }else{ //echo 'success'; } } if ((isset($_FILES['file1'])) || (isset($_FILES['file2'])) || (isset($_FILES['file3']))){ //don't print form if upload is set } else { ?> <form action="" method="post" enctype="multipart/form-data"> <div> <input type="file" name="file1" /> <br> <input type="file" name="file2" /> <br> <input type="file" name="file3" /> <input type="submit" value="Upload" /> </div> </form> <?php } ?> </body> </html>That max filesize should be 10MB, anything uploaded above that size just returns to the upload form with no errors, I need it to return an error if the file is too big.
Thanks for your time.