Re: [symfony-users] File size validation?

2010-01-07 Thread Nathan
This is actually a php limit. Not a Symfony one. There's not much you can do
besides increasing your php max_post_size value. (but I wouldn't do this).

Nathan

--
nathan @  nathan.gs



On Thu, Jan 7, 2010 at 11:11 AM, Mark Smith  wrote:

> Hi,
>
> I am trying to implement file size validation for an upload field on a
> form.
>
> For security / performance the php.ini post_max_size config setting is
> set to 8 mb.
>
> Now I want to limit the file size upload to about 1 mb. I am using the
> built in sfValidatorFile:
>
> $this->setValidator("file", new sfValidatorFile(array('max_size' =>
> 100, 'mime_types' => array('text/plain'),'required'=>false)));
>
> This works ok if the user uploads a 2 mb file, but if the
> post_max_size is exceeded by the user trying to upload a file of say
> 10mb, a 500 error page is produced! This is not very friendly and it
> makes it look like the page is broken, when actually it is a simple
> validation error.
>
> A way to request the browser to limit the file size would be
> acceptable, and the 500 page would be reserved for bad requests
> But sadly after a quick google it doesn't look like that is possible.
>
> How should this problem be dealt with?
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "symfony users" group.
> To post to this group, send email to symfony-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> symfony-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/symfony-users?hl=en.
>
>
>
>
-- 

You received this message because you are subscribed to the Google Groups "symfony users" group.

To post to this group, send email to symfony-us...@googlegroups.com.

To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en.



[symfony-users] File size validation?

2010-01-07 Thread Mark Smith
Hi,

I am trying to implement file size validation for an upload field on a
form.

For security / performance the php.ini post_max_size config setting is
set to 8 mb.

Now I want to limit the file size upload to about 1 mb. I am using the
built in sfValidatorFile:

$this->setValidator("file", new sfValidatorFile(array('max_size' =>
100, 'mime_types' => array('text/plain'),'required'=>false)));

This works ok if the user uploads a 2 mb file, but if the
post_max_size is exceeded by the user trying to upload a file of say
10mb, a 500 error page is produced! This is not very friendly and it
makes it look like the page is broken, when actually it is a simple
validation error.

A way to request the browser to limit the file size would be
acceptable, and the 500 page would be reserved for bad requests
But sadly after a quick google it doesn't look like that is possible.

How should this problem be dealt with?

Thanks
-- 
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-us...@googlegroups.com.
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en.




[symfony-users] File Size validation not working...

2008-05-22 Thread Sumedh

I want to allow users to upload image files of upto 1 MB in size...

I tried with YML...

fields:
...
  file:
file:   True
sfFileValidator:
  mime_types:
- 'image/jpeg'
- 'image/png'
- 'image/gif'
- 'image/bmp'
  mime_types_error: Please upload only PNG, JPEG, GIF, BMP images
  max_size: 1024000
  max_size_error:   Max size is 1024Kb

It doesn't work...it correctly checks for file type...but it doesn't
give any error for file size...it doesn't upload it either if it's
greater than 1 MB...but doesn't generate any error...just goes to
success page...



In code, I tried this -

$fileName = $this->getRequest()->getFileName('file');
$fileSize = $this->getRequest()->getFileSize($fileName);
$this->logMessage(" file size = " . $fileSize);

And I get nothing in the fileSize variable...though I get fileName
correctly...

So, a simple task is eating up all the time... :(

Any ideas?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---