Hi all,
I am posting here to see if any of you can help with my problem. I have a client who would like to receive the file size of uploaded images directly in the admin notification email after a form submission.
I have done the following: I added a hidden 'File Size' field on the form. I also added an addaction for gform_pre_submission. This is shown in the pasted code. So my plan here is inside the function that is called by the gform_submission I will had a php filesize to get the size in bytes of that file, and then change the value of the filesize input.
My problem is I can not for the life of my figure out how to get the URL of the file inside this function. I figured out how to do it in the gform_post_submission hook, but by this hook the email has all ready sent :/ . I feel there must be a way to do this since the email sends a link directly to the file, i just cant find out where this is happening. Any suggestions here? Much appreciated in advance.
//Gravity Forms include File Size In Admin Notification Email
add_action("gform_pre_submission", "pre_submission_handler");
function pre_submission_handler($entry, $form){
/*
How Do I Get $url here?
$fileSize = filesize($url);
if ($fileSize < 1024) {
echo $fileSize .' B';
} elseif ($fileSize < 1048576) {
echo round($fileSize / 1024, 2) .' KB';
} elseif ($fileSize < 1073741824) {
echo round($fileSize / 1048576, 2) . ' MB';
}*/
$_POST['input_22'] = 'SizeHere';
}
//This is the working hook/filter, its just too late to change the field name since the file has all ready been sent.
add_action("gform_post_submission", "post_sendmail_handler", 10, 2);
function post_sendmail_handler($entry, $form){
$url = $entry[2];
}