Re: max_file_size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sebastian wrote:

Each time i try setting MAX_FILE_SIZE in a form and using the upload error code to check if the file is large it always uploads the entire file before showing the error that the file is too big.. either the manual is incorrect or this does not work as every method i've tried always waits for the file to be uploaded before it errors. eg:

<form enctype="multipart/form-data" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="1048576" />
<input type="file" name="userfile" size="29" />
<input type="submit" name="submit" value="Upload" />
</form>

switch($_FILES['userfile']['error'])
{
  case 1:
   $message[] = 'Error #1 - ...';
  break;

  case 2:
   $message[] = 'Error #2 - File is too big';
  break;

  case 3:
   $message[] = 'Error #3 - File was partially uploaded';
  break;
}

--snip
-- IF no error then start upload...
--snip

yet it waits for file to upload before error.
I've been using php for serveral years and i cant remember ever getting this to work like the manual states.

From the manual:
"The MAX_FILE_SIZE hidden field (measured in bytes) must precede the file input field, and its value is the maximum filesize accepted. This is an advisory to the browser, PHP also checks it. Fooling this setting on the browser side is quite easy, so never rely on files with a greater size being blocked by this feature. The PHP settings for maximum-size, however, cannot be fooled. This form element should always be used as it saves users the trouble of waiting for a big file being transferred only to find that it was too big and the transfer failed."

From my understanding of this paragraph, MAX_FILE_SIZE is checked by PHP but I dont see how you can infer that PHP is able to do this on the client. If any client side intervention is to be performed then it should be done by the browser. If you also look at the upload errors generated by PHP (http://uk.php.net/manual/en/features.file-upload.errors.php) you can see that these can only be generated on the server, and therefore *after* the file has been posted.

I think it is your browser that you need to be investigating...

HTH,

Mikey

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux