Hello.

CGI.pm module can restrict the size of the file being uploaded.
You canb use something like this:

my $max_size = 512000; #For 500kb limit

$CGI::POST_MAX=$max_size;

If the file size is bigger than that, it stop the process and returns an
error message.


But, thinking about it now, it's better to know the size of the file and
don't even waste time trying to upload it if it's too big, than begin the
upload and finish it if you get to the limit.

It may be a good idea to use the -s flag as 'awarsd' said to decide if
begining the upload process, but keep CGI::POST_MAX for security reasons.

-rm-


----- Original Message -----
From: "Mike Harrison" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 17, 2003 9:03 PM
Subject: File uploading


> Hello,
>
> I have a perl program that allows a user to upload a file (either .jpg or
> .gif) to the server, and returns a message if it exceeds a specified size
> (in my case 100kB).  Currently (and don't laugh - I am new to perl), I go
> through the motions of uploading the file in 1024-byte blocks (in binary
> mode), and increment a counter with each block.  If the counter exceeds
100
> (i.e. greater than 100kB), then it exits the loop, displays a warning
> message and deletes the file.
>
> I am sure there would have to be an easier and more efficient way of doing
> this - that is, somehow finding out how large the file is without having
to
> download it first.
>
> Does perl have a module that can check the size of the file?  And for that
> matter, its type (.jpg, .gif etc.)?
>
> Thanks in advance,
> Mike.
>



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to