FORUMS


The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Show error if file upload exceeds limit
#1
When files being uploaded exceed the limit there needs to be an error message stating that the file is too large. Currently if the file is too large a 500 Internal Server Error is displayed and the message get's sent with no files.
Reply
#2
(Apr 20th, 2012, 2:29 PM)JediCharles Wrote: When files being uploaded exceed the limit there needs to be an error message stating that the file is too large. Currently if the file is too large a 500 Internal Server Error is displayed and the message get's sent with no files.

I solved that issue using javascript placed at the beginning of the process.php file located in the formtools installation folder.

$max_filesize = 524288;
// Maximum filesize in BYTES (currently 0.5MB).

$upload_path = '../formtools/upload/'; // change to your upload path

$filename = $_FILES['userfile']['name'];
// Get the name of the file (including file extension).

$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1);
// Get the extension from the filename.

// Now check the filesize, if it is too large then DIE and inform the user.
if(filesize($_FILES['userfile']['name']) > $max_filesize)
die('The file you attempted to upload is too large.');

Then add to 'die'.
<a href="#" onclick="history.go(-1);return false;">BACK</a>

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)