• Resolved murdermitten

    (@murdermitten)


    Hi,

    How do I programmatically get the url submitted from a file upload field?

    I’m using the “fluentform_before_insert_submission” hook and here’s the code that I use to get the data from the file upload field:

    $file_url = \FluentForm\Framework\Helpers\ArrayHelper::get($data, ‘file_upload’);

    It was working before but now it’s not returning a valid url anymore.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello @murdermitten,

    You can use the hook fluentform_submission_inserted instead of using the fluentform_before_insert_submission to get an exact upload path.

    Thank you.

    Plugin Support Alex Sanchez

    (@alexwpninja)

    Hello, here is in example code to get the file name using ‘fluentform_before_insert_submission’ action hook.

    add_action( 'fluentform_before_insert_submission', function( $insertData, $data, $form){
    	
    	
    	$files = $data['file-upload'];
    	$uploadDir = str_replace('/', '\/', FLUENTFORM_UPLOAD_DIR );
                
    	$pattern = "/(?<=${uploadDir}\/).*$/";
    
    	preg_match($pattern, $files[0], $match);
    
    	if (!empty($match)) {
    		$file = str_replace($match[0], \FluentForm\App\Helpers\Protector::decrypt($match[0]), $files[0]);
    	}
    	dd($file);
    } ,10,3);

    Hope that helps.
    Thanks

    • This reply was modified 3 years, 10 months ago by Alex Sanchez.
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Get File Upload URL’ is closed to new replies.