Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

Looking at upload size/type before it is uploaded?

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


amurkat at gmail

Jul 10, 2009, 8:36 AM

Post #1 of 2 (762 views)
Permalink
Looking at upload size/type before it is uploaded?

What's the recommended way to validate file upload's size and type
(either filename or MIME) before downloading it into the temp
directory? I don't want the user to be able to upload a 200 MB file in
its entirety before having the controller reject it for being too big.

Thanks.
-amurka

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


bobtfish at bobtfish

Jul 11, 2009, 5:56 AM

Post #2 of 2 (687 views)
Permalink
Re: Looking at upload size/type before it is uploaded? [In reply to]

On 10 Jul 2009, at 16:36, A Murka wrote:

> What's the recommended way to validate file upload's size and type
> (either filename or MIME) before downloading it into the temp
> directory? I don't want the user to be able to upload a 200 MB file in
> its entirety before having the controller reject it for being too big.

You're looking for http://search.cpan.org/~flora/Catalyst-
Runtime-5.80007/lib/Catalyst.pm#ON-DEMAND_PARSER

Set that, and the body of the request will only be read when you
access it. So you can check the content-length (and other headers)
and reject the request before the rest of the content arrives...

Cheers
t0m



_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.