Page 1 of 1

MAX_FILE_SIZE (Uploading Multiple Files)

Posted: Tue Apr 13, 2004 4:50 pm
by zenabi
This is an example of a HTML form for uploading a file, similar to the one on php.net.

Code: Select all

<form enctype="multipart/form-data" action="_URL_" method="post">
   <input type="hidden" name="MAX_FILE_SIZE" value="30000" />
   File 1: <input name="userfile" type="file" />
   <input type="submit" value="Send" />
</form>
Now say I wanted to upload two files at once, but each with a different maximum file size setting, I will have something like this:

Code: Select all

<form enctype="multipart/form-data" action="_URL_" method="post">
   <input type="hidden" name="MAX_FILE_SIZE" value="30000" />
   File 1: <input name="userfile1" type="file" />

   <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
   File 2: <input name="userfile2" type="file" />

   <input type="submit" value="Send" />
</form>
Notice there are now two hidden input elements with the same name (MAX_FILE_SIZE). Am I correct in saying that the second hidden input element would take precedence over the first and effectively make both inputs have the same maximum file size?

Apologies if that was explained badly :oops: , but I would be very grateful if someone could find a way to have each input element with its own maximum file size setting.

Posted: Tue Apr 13, 2004 4:53 pm
by mudkicker
I think it can't be that way you wrote. But you can check it with PHP after you post it.

You can check the files' sizes both. and return an error.

$_FILES['userfile']['size']

Posted: Tue Apr 13, 2004 5:09 pm
by zenabi
Thanks for the quick reply!

I have thought of your way, but I want the users to know their files are too big before they upload them.

Any ideas?

Posted: Wed Apr 14, 2004 3:27 am
by mudkicker
well you cannot do it via Javascript onlu ActiveX in IE (that sux)... I think you should use PHP for validation; with that MAX_FILE_SIZE... I don't think it works..

Posted: Wed Apr 14, 2004 4:02 am
by vigge89
yuo could use multiple forms, and have the submit button on the last one submit all of thenm, but i'm not sure if it's possible...