On Tue, 2005-07-12 at 11:35 -0400, 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.
> 

There is no way for you to check the file's size before it gets fully
uploaded. This happens because Apache only checks the filesize when it's
on the server's temporary files. The client doesn't send any info about
the file except it's name and it's contents.

Even if you want to turn to javascript, I don't think there's a way to
do what you want to do. File input fields can only be read from my
experience, and through javascript there isn't any way to access a
file's properties through the client-side unless you have some sort of
ActiveX control or somesuch.

The only thing I saw that would do that was a Java applet :)

Good luck!

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

Reply via email to