Introduction
Would you like to send multiple files uploaded to your WPForms to Google Drive with the Zapier addon? By default, the zap will only send through one file from the form, but when you add a small PHP snippet to your site, you can accept multiple files. In this tutorial, we’re going to set up a form that will accept multiple file uploads and using Zapier push them to Google Drive.
Creating your form
This tutorial is based on the documentation from How to Send WordPress Uploads to Google Drive (Easily). Follow this guide in setting up your form, your Zapier connection, and creating your zap.
Our form will have the Name, Email, File Upload and Paragraph Text form fields.
Adding the snippet to send multiple files
We’ll need to add a small code snippet that will allow us to use this zap to send more than just one file to Google.
If you need help in adding code snippets to your site, please see this tutorial.
/** * Send multiple files to Google Drive with Zapier addon * * @link https://wpforms.com/developers/how-to-send-multiple-files-to-google-drive-with-zapier/ */ function wpf_dev_add_zapier_file_upload_filter($data, $entry_id, $form_data) { $fields = wpforms_get_form_fields( $form_data ); foreach ( $fields as $field_id => $field ) { if ( $field['type'] === 'file-upload' ) { $data[ 'field'.$field_id ] = explode( "\n", stripslashes( $data[ 'field'.$field_id ] ) ); } } return $data; } add_filter('wpforms_zapier_process_entry_data', 'wpf_dev_add_zapier_file_upload_filter', 10, 3);
This snippet will take every file name and place it on a new line, which in turn, will allow for multiple files.
Viewing these files on Google Drive
What happens when the form is completed that it will send the files to Google Drive.
In order to view these images, you’ll need to unzip them. To do this, open the file that was just sent to your Google Drive. Then from the dropdown menu in the top center of the screen, click Open With and choose Zip Extractor.
The zipped file will display with a list of the images or files attached to that zip, just select Extract, and all the files will be extracted.
Now you’ll see the parent directory with the attached images or files inside your Google Drive.
Would you like to also change the timeout when using the Modern File Upload field? Check out our tutorial on How to Change the Timeout on the Modern File Upload.