After reviewing the database and code, I can see that it is uploading the file to our S3 server but storing the local url in the database. Here is the database entry (I removed the local domain name for privacy):
{s:2:"id";s:1:"5";s:4:"slug";s:11:"file-upload";s:4:"name";s:11:"File Upload";s:4:"type";s:11:"file-upload";s:7:"options";s:31:"a:1:{i:0;s:13:"png|jpe?g|gif";}";s:9:"parent_id";s:1:"0";s:5:"value";s:74:"<local domain name removed>/wp-content/uploads/2016/06/IMG_5815.jpg";}i:3;a:7:}
Here is the relevant code in email.php (which emails the form and stores it in the database):
// Handle attachments
if ( $field->field_type == 'file-upload' ) :
$value = ( isset( $_FILES[ 'vfb-' . $field->field_id ] ) ) ? $_FILES[ 'vfb-' . $field->field_id ] : '';
if ( is_array( $value) && $value['size'] > 0 ) :
// 25MB is the max size allowed
$size = apply_filters( 'vfb_max_file_size', $settings_max_upload );
$max_attach_size = $size * 1048576;
// Display error if file size has been exceeded
if ( $value['size'] > $max_attach_size )
wp_die( sprintf( __( "File size exceeds %dMB. Please decrease the file size and try again.", 'visual-form-builder' ), $size ), '', array( 'back_link' => true ) );
// Options array for the wp_handle_upload function. 'test_form' => false
$upload_overrides = array( 'test_form' => false );
// We need to include the file that runs the wp_handle_upload function
require_once( ABSPATH . 'wp-admin/includes/file.php' );
// Handle the upload using WP's wp_handle_upload function. Takes the posted file and an options array
$uploaded_file = wp_handle_upload( $value, $upload_overrides );
// If the wp_handle_upload call returned a local path for the image
if ( isset( $uploaded_file['file'] ) ) :
// Retrieve the file type from the file name. Returns an array with extension and mime type
$wp_filetype = wp_check_filetype( basename( $uploaded_file['file'] ), null );
// Return the current upload directory location
$wp_upload_dir = wp_upload_dir();
$media_upload = array(
'guid' => $wp_upload_dir['url'] . '/' . basename( $uploaded_file['file'] ),
'post_mime_type' => $wp_filetype['type'],
'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $uploaded_file['file'] ) ),
'post_content' => '',
'post_status' => 'inherit'
);
// Insert attachment into Media Library and get attachment ID
$attach_id = wp_insert_attachment( $media_upload, $uploaded_file['file'] );
// Include the file that runs wp_generate_attachment_metadata()
require_once( ABSPATH . 'wp-admin/includes/image.php' );
require_once( ABSPATH . 'wp-admin/includes/media.php' );
// Setup attachment metadata
$attach_data = wp_generate_attachment_metadata( $attach_id, $uploaded_file['file'] );
// Update the attachment metadata
wp_update_attachment_metadata( $attach_id, $attach_data );
$attachments[ 'vfb-' . $field->field_id ] = $uploaded_file['file'];
$data[] = array(
'id' => $field->field_id,
'slug' => $field->field_key,
'name' => $field->field_name,
'type' => $field->field_type,
'options' => $field->field_options,
'parent_id' => $field->field_parent,
'value' => $uploaded_file['url']
);
$body .= sprintf(
'<tr>
<td><strong>%1$s: </strong></td>
<td><a href="%2$s">%2$s</a></td>
</tr>' . "\n",
stripslashes( $field->field_name ),
$uploaded_file['url']
);
endif;