How to Get the URL from the File Upload Form Field


Do you need to get the URL from your File Upload form field? In some cases, you may want to pass through this URL to a CRM or use it in a cURL function. In this tutorial, we’ll show you how to get the URL from the File Upload form field.


First, you’ll need to add the File Upload form field to your form. If you need assistance with that, please review our tutorial on A Complete Guide to the File Upload Field.

Next, copy and paste the code shown below into your site.

The code shown below will assign any file uploaded to the $myfileurl variable as separate links for each file.

 * How to get the URL field from the File Upload field
 * @link
 * @param array  $fields    Sanitized entry field values/properties.
 * @param array  $entry     Original $_POST global.
 * @param array  $form_data Form data and settings.
 * @param int    $entry_id  Entry ID. Will return 0 if entry storage is disabled or using WPForms Lite.

function wpf_dev_process_complete( $fields, $entry, $form_data, $entry_id ) {
    // Optional, you can limit to specific forms. Below, we restrict output 
    // to form #178.
    if ( absint( $form_data['id'] ) !== 178 ) {
    // Get the URL of the File Upload field  
    $myfileurl = $fields['5']['value'];

    // Run code
add_action( 'wpforms_process_complete', 'wpf_dev_process_complete', 10, 4 );

And that’s it! You’ve successfully saved the URL of the file uploaded through your form. Would you like to hide the image choices on your email notifications? Take a look at our article on How to Hide Image Choices in Notification Emails.


Action Reference: wpforms_process_complete