Home / Admin / How to Get the URL from the File Upload Form Field
Duplicate Snippet

Embed Snippet on Your Site

How to Get the URL from the File Upload Form Field

<10
Code Preview
php
<?php
/**
 * Get and use the File Upload field URL 
 *
 * @link https://wpforms.com/developers/how-to-get-the-url-from-the-file-upload-form-field/
 */
 
function wpf_dev_frontend_confirmation_message( $message, $form_data, $fields, $entry_id ) {
     
    // Only run on my form with ID = 1000
    if ( absint( $form_data[ 'id' ] ) !== 1000 ) {
        return $message;
    }
 
    // Grab the URL of the single image uploaded to the form
    $myfileurl = $fields[ '10' ][ 'value' ];
	
	// Echo out the image under the confirmation message
	$image .= '<div class="image_container"><img src="' . $myfileurl . '" class="small"></div>';
 
    $message = '<p>' . esc_html__( 'Thank you for your submission. Below is the image you uploaded for our contest. Watch your email for the winner to be notified on July 31st.', 'plugin-domain' ) . '</p>';
 
    return $message . '<p>' . $image . '</p>';
     
}
add_filter( 'wpforms_frontend_confirmation_message', 'wpf_dev_frontend_confirmation_message', 10, 4 );

Comments

Add a Comment