hi again
sorry, me
i am trying to restrict file upload size (ideally also type of file).
I have this code in my functions:
add_filter(‘frm_validate_field_entry’, ‘validate_custom_file_size’, 10, 3);
function validate_custom_file_size($errors, $field, $value){
if ($field->type == ‘file’ and (isset($_FILES['file'.$field->id])) and !empty($_FILES['file'.$field->id]['name'])){ //check if the file is too big
if ((int)$_FILES['file'.$field->id]['size'] > 5000000){ //change this number to the max size you would like. 100000 bytes = 1 KB
$errors['field'.$field->id] = ‘The file(s) are too big. Please upload another or resize.’;
}
}
return $errors;
}
but it still lets me upload files over this size i.e. 1.5mb.
Do I need to somehow specify the form to apply the restriction on? or the field id? (i have more than one form that allwos file uploads and one form in particular allows 10 file uploads (i am trying to restrict the file size as I think we hit a bug in F.pro – on the form that allows 10 images (its a multi page form) if the user uploads 10 images and the yare quite large and they submit the form the uploading image bits all happen but, once done instead of taking them to their redirect page they get take back to the fisrt part/page of the form and all the data is lost
so trying to figure out why this is happening)
is there a way to restrict file type upload, in G.Forms you can select what file types are allowed, which is nifty, although not a good enough reason to use the inferior product, as F.Pro is massively more flexible
Thanks
Darren




May 21, 2012 at 9:17 pm
You can restrict file types in the field options for each upload field.
For the large total upload, there are likely a few server settings (max time, and post max settings) that need to be increased. Please see this knowledge base page for more info.
http://formidablepro.com/knowledgebase/using-file-upload-fields/
5000000 bytes = 5 mb. It looks like you need to decrease this number if you don't want files over 1.5 mb to be uploaded.
May 22, 2012 at 2:06 am
ah, i knew i had seen that file type restriction somewhere and i couldnt see it in FP so assumed it was in the (dare i say it) GF, but, actually it wasnt, it was your superb product!
got file size restriction working as well, so all good :-) still need to investage the blanking of hte form as this was on my local machine so don't believe it was restrictions or time outs, but i shall investigate further.
thanks, once again a great product
D
Topic closed.