Want to allow CSV uploads in WordPress?
Letting your visitors attach CSV files to forms can help you to easily accept information stored in tables.
In this article, we’ll show you how to easily create a CSV upload form in WordPress.
Here’s a table of contents so you can easily find each section:
- Create Your CSV Upload Form in WordPress
- Switch to the Classic Style File Upload Field (Optional)
- Configure Your CSV Upload Form Settings
- Customize Your CSV Upload Form’s Notifications
- Configure Your CSV Upload Form’s Confirmations
- Add Your CSV Upload Form to Your Website
- View the Files
Why Use a CSV Upload Field on Your WordPress Forms?
CSV stands for comma-separated value. It’s basically just a plain text file that has a bunch of data inside of it. These kinds of files store data in tables.
So they pretty much exist to make it easier to send that data from one app to another.
For instance, here are some real-life reasons you may want to let visitors upload a CSV file:
- You’re gathering timesheets for employees working on a personal improvement plan
- To collect nutrition diaries for customers on health or wellbeing plans
- You want to store Inventory details for an equipment checkout form
- To gather financial information for a mortgage application
- To collect bulk purchases for a wholesale order form
- To get payments with your file uploads
- You want to create an RSVP form in WordPress and let your visitors upload attachments.
You can probably think of a bunch more.
It’s really easy to allow CSV uploads in WordPress. You can collect data in CSV files from any page on your website.
WordPress blocks some file types for security reasons. But most image files can be uploaded using WPForms, and CSV files are allowed by default. If you have issues with other file types, read our guide on how to allow additional file upload types.
Let’s create our first CSV upload form.
How to Create a CSV Upload Form in WordPress
In this article, we’ll use the WPForms plugin to quickly create a form that will allow CSV file uploads in WordPress.
We’ve broken it down into 7 steps.
Step 1: Create Your CSV Upload Form in WordPress
To create your CSV upload form, you’ll need to install the WPForms plugin.
WPForms is the best file upload plugin for WordPress. It makes it really easy to create a form for any purpose using a drag and drop builder.
Once you’ve created your CSV upload form, you can display it anywhere on your site. You can even place it in the sidebar.
If you need a little help getting the WPForms plugin installed, see this step-by-step guide on how to install a plugin in WordPress.
Once you have WPForms installed, activate the plugin. You’ll see WPForms in the left-hand navigation menu in the WordPress dashboard.
Click WPForms » Add New to create a new form. Type a name for your form at the top.
Let’s start with a template and then customize it to allow CSV uploads.
In WPForms, scroll down to the Additional Templates section. Search for “File Upload Form” and click on it.
If you don’t see the File Upload Form, you might need to activate the Form Templates Pack Addon.
WPForms will create a blank form with 4 fields: Name, Email, Phone, and File Upload.
To add more fields to the form, drag and drop the field you want to add from the left-hand panel to the right-hand panel.
You can also change the order of the fields. Click on the field you want to move and drag it up or down.
Do you already have a form that you want to use for CSV uploads? You can easily add the File Upload field to it. Open the form in the WPForms editor, expand the Fancy Fields drop-down, and drag a File Upload field from the left-hand panel to the right-hand panel.
Now you have a file upload field on your form. By default, it will allow many different file types to be uploaded.
To only allow CSV files to be uploaded, click on the File Upload field. In the Allowed File Extensions field, type csv.
Sometimes applications save CSV files in a different format. To make things easier for your visitors, you may want to allow those formats too.
For example, to allow Excel formatted files and CSV files to be uploaded, you would type csv,xls,xlsx in the Allow File Extensions field.
You can change other options to control the file upload field:
- Label — Give the Form Upload field a label like Upload Your CSV File so your visitors know what the field is for.
- Description — Add a description. For example, you might want to specify which file extensions your visitors can upload.
- Max File Size — Specify the maximum size of the CSV file users can upload. If you don’t specify a number here, WPForms will default to the maximum file size that your server allows. If you need to change this, see this tutorial on how to increase the maximum file upload size in in WordPress.
- Required — If this is checked, your visitor must attach a CSV file before they can submit the form.
- Style — You can choose the Modern style file uploader (recommended) or the Classic style (which we’ll explain in Step 2, below).
So, once your user submits a form, what happens next?
By default, WPForms will save CSV files into a folder called WPForms in the WordPress Uploads directory. You can access the files by connecting to your web host via FTP.
It’s a lot easier to have WPForms save the files into your WordPress Media Library so you can access them right from the WordPress dashboard.
To do this, click on your File Upload field. Expand the Advanced Options drop-down and check Store file in WordPress Media Library.
We’re done creating our simple upload form!
If you have a complicated form, you can make it easier to navigate by following our tutorial on how to create a multi-step form in WordPress.
Step 2: Switch to the Classic Style File Upload Field (Optional)
The Modern file upload style is great for all forms. It lets users drag as many files as they want onto your Form Upload field.
But there are two reasons you may need to switch to the Classic style instead of the Modern style:
- You (or your visitors) prefer to click a ‘Choose Now’ button to select their CSV file
- You want the File Upload field to be smaller in size.
If you’d like to switch to the Classic style, you can do that by clicking on the File Upload field and selecting Classic the Style drop-down list.
Keep in mind that the Classic style upload field only accepts one file.
If you want to use the Classic field for multiple file uploads, you can enable conditional logic. This lets you add multiple File Upload fields. The extra fields will only show up if your user needs them.
That helps to keep the form compact.
If you don’t need to let users upload multiple CSV files, you can skip the rest of this section.
We need to first ask the visitor how many files they want to upload, then display the corresponding number of Classic File Upload fields.
We’ll create 3 fields in this example, but you can display as many as you want.
To begin, drag a drop-down list field onto your form. Place it above the File Upload field.
Click on the drop-down list field to change the settings. Let’s change the Label to ‘Number of CSV Files to Upload’. Under Choices, add 3 drop-down list items: 1, 2, and 3.
Next, click the File Upload field. Scroll down to the Conditionals section and expand it. Then check the Enable conditional logic box.
Now you need to create the conditional logic for the field. Just match yours to the screenshot below:
Be sure to add the fields using the Add new group button so that your form uses OR logic. If you need more information about AND and OR logic, read our guide on how to use AND/ OR logic in WPForms.
Now we’ll add the second File Upload field. Click the duplicate icon on the right-hand side of the Form Upload field to create a copy of it.
Click on the second File Upload field and change the Label to ‘Upload Your Second CSV File’.
Set up the conditional logic for this field as in the screenshot below. We removed the first action, Number of Files to Upload is 1. The other two actions are the same.
Now, the second field will show up if the user selects 2 or 3 in the drop-down list.
Next, duplicate the second File Upload field to create a third one. This time, label it Upload Your Third CSV File.
Here’s what the logic for the third field looks like. This time, we removed the Number of Files is 2 action.
And that’s it. Easy, right?
Click Save at the top-right of the WPForms screen to save your form.
So it’s much easier to use the Modern style if you want to accept multiple CSV uploads. But now you know how to use the Classic style to allow CSV file uploads in WordPress when your visitor has more than one file.
Now we can configure the settings for the form.
Step 3: Configure Your CSV Upload Form Settings
Click Settings » General to open your form settings.
In this section, you can configure the following options:
- Form Name — Edit the name of your form.
- Form Description — Add a description for your form. You can choose to display the description above the form when you embed it on your site.
- Submit Button Text — Customize the wording on the Submit button.
- Spam Prevention — Stop spammers from submitting junk entries through your contact form. You can use the anti-spam feature, custom CAPTCHA, hCaptcha, or Google reCAPTCHA. Keep in mind that the anti-spam feature is enabled on all new forms by default.
- AJAX Forms — Enable AJAX settings so the form can be submitted without reloading the page.
- GDPR Enhancements — Make your form GDPR compliant. This will reduce the amount of data that the form captures about your visitors. If your form is likely to be used by people who live in the European Union, you might need to check this. For more details, see our guide on how to add a GDPR Agreement Field to your site’s forms.
Click Save when you’re done.
Step 4: Customize Your CSV Upload Form’s Notifications
You can choose how you’d like to be notified when someone submits your form.
By default, every form has email notifications switched on. You can customize the email notification, or turn it off, in the Settings » Notifications panel.
If you need help getting these notification emails set up, you can read our guide on setting up form notifications in WordPress.
You can also send a notification to your visitor automatically when they submit a form. This is a great way to let them know that you received their file. To set this up, you’ll need to use smart tags in your notification template.
You could also send the CSV file to other departments in your company. For example, you could have all of your wholesale orders go to the fulfillment center.
To send multiple notifications, read our guide on sending multiple form notifications in WordPress.
If you’d like to brand your emails, WPForms can add an image or company logo to notification emails as a custom header image. Your logo will show up at the top of the email, like in the screenshot below.
It’s important to note that WPForms doesn’t include file uploads as attachments when it sends out notifications. That’s because most email providers limit the size of attachments, so your notifications might fail.
Instead, WPForms provides a link to the file in the notification email. Just click the link to view or download the file.
Step 5: Configure Your CSV Upload Form Confirmations
Confirmations are actions that automatically happen when a form is submitted. If you need more help with this, read our tutorial on how to set up form Confirmations.
You can choose between three different types of Confirmations:
- Message — Displays a message to confirm that the form has been submitted. This is the default Confirmation for every form. You can customize it if you want to.
- Display Page — Automatically displays a page or post on your site when the form is submitted.
- Redirect — Automatically loads a page on another website.
For our CSV upload form, let’s display a simple confirmation message.
Head back to the form editor and open your form. Click Settings » Confirmation.
In the Confirmation Type drop-down, select Message.
Create the message and click Save.
All done! Everything’s complete, except for one important step. Let’s put the CSV upload form onto your website.
Step 6: Add Your CSV Upload Form to Your Website
WPForms lets you add forms anywhere in WordPress: a page, a post, or in the sidebar. We’re going to add it to a new page in this example.
Create a new page. In the Block Editor, click the plus icon.
In the menu that appears, scroll down to Widgets, and then click WPForms.
The WPForms widget will load in the Block editor. In the drop-down list, select the CSV upload form.
Next, click the blue Publish or Update button at the top-right corner.
You’re all done! Your new CSV upload file is now live on your website and ready for your visitors to upload their files.
Step 7: View the CSV Files
You can view all of the form submissions you’ve received in the WordPress dashboard. Click on WPForms » Entries, then use the drop-down list at the top-left to view the entries for the CSV upload form.
To view each individual form submission, click the View link on the right-hand side of the row.
You can save or open the files the user uploaded by clicking the link.
Final Thoughts on Allowing WordPress CSV Uploads
That’s it! Now you know how to allow CSV file uploads in WordPress.
If you’d like to create a sidebar widget for your CSV upload forms, check out how to create a file upload widget in WordPress.
Did you know that you can also export WordPress form entries in CSV format? It’s a great way to view your contact form entries in Excel.
Ready to build your CSV upload form? Get started today with the easiest WordPress form builder plugin. WPForms Pro includes a free file upload form and offers a 14-day money-back guarantee.