• dr.techy

    (@drtechy)


    Hi i have a CF7 form with file upload field. I am using Contact Form DB (Thanks for this awesome plugin) for saving entries.

    now i want to change the file name to something like (filename.pdf to username_date_filename.pdf)

    I read ur tutorial on modifying data before saving but i am unable to get the way to do this because my PHP knowledge is very limited. Can u please help me with how to accomplish this.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Thread Starter dr.techy

    (@drtechy)

    I am trying to use this function into “shortcode actions & filters” plugin, but the filename is not changed

    function changefilename ($formData){
        $formName = 'vbdcp'; // change this to your form's name
    	
    	// CHANGE THIS: upload field name on your form
        $fieldName = 'VBDCPReport'; 
        
    	if ($formData && $formName == $formData->title && isset($formData->uploaded_files[$fieldName])) {
           
            $path = pathinfo($formCopy->uploaded_files[$fieldName]);
          
    	$newfile = $formData->posted_data['InstituteName'] . '_' . $path['basename'];
     
    	$formData->posted_data['NVBDCPReport'] = $newfile;
    		
        }
        return $formData;
    }
     
    add_filter('cfdb_form_data', 'changefilename');

    please guide me with correct method…

    • This reply was modified 8 years ago by dr.techy.
Viewing 1 replies (of 1 total)

The topic ‘Remane attached files with forms before saving’ is closed to new replies.