Skip Navigation

[Resolved] cred_form_validate file_data size isn't being set?

This support ticket is created 5 years, 12 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 10:00 - - - - -
- - - - - - -

Supporter timezone: Africa/Cairo (GMT+02:00)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by Mohammed 5 years, 11 months ago.

Assisted by: Mohammed.

Author
Posts
#631263

I am trying to: limit a file upload size

I used this script:

//Limit upload file size for repeating image custom field
add_filter('cred_form_validate','story_image_size_validation',10,2);
function story_image_size_validation($field_data, $form_data) {
list($fields,$errors)=$field_data;
$arr = array(17, 4098);
if (in_array($form_data[id], $arr)){
if(isset($fields['wpcf-trade-logo']['file_data']['size'])){
if($fields['wpcf-trade-logo']['file_data']['size']>1000){
$file_size = $fields['wpcf-trade-logo']['file_data']['size'];
print_r('Size exceeded: ' . var_dump($file_size)); die();
$errors['trade-logo']='the image size should not be more than 1000 bytes';
}
}
}
return array($fields,$errors);
}

The function is being called as expected - form id is 17. I've tried various re-workings of the script and cannot dump the file_data

Link to a page where the issue can be seen: will provide URL in site info page is: /edit-trades-profile/

I expected to see: error message for filesize exceeded.

Instead, I got: Image uploaded without error

** Duplicator is banned on my server.

#631384

Hi James,

I'm able to see the issue on a clean install, so, there is no need for the duplicator package.

I'm going to report this so that it can be handled by the second tier.

Please keep following this ticket and I will notify you once I get any updates.

Thanks.

#631395

Hi James,

Can you try the cred_form_ajax_upload_validate hook: https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_ajax_upload_validate

We upload the images using Ajax, that's why we added this hook tio handle images uploads.

I hoe it hepl you.

Thanks.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.