Handling file uploads from Contact Form 7 can be tricky, especially when you want those files sent directly to another platform. Fortunately, the Contact Form to Any API plugin makes this process seamless by allowing file attachments to be transferred alongside form data to any external API.
Step 1: Set Up Your Contact Form 7 with File Upload Field
Begin by adding a file upload field to your Contact Form 7 form. Use the [file] tag, like so:
[file your-file limit:10mb filetypes:pdf|doc|docx|jpg|png]
This allows users to upload files up to 10MB with accepted formats like PDFs, Word documents, and images.
Step 2: Install and Configure Contact Form to Any API
If you haven’t already, install the Contact Form to Any API plugin. Once installed:
- Go to your WordPress dashboard.
- Navigate to Contact > Contact to API.
- Choose the form you want to connect.
- Enter the endpoint of the API you want to send data to (e.g., a CRM, file management service, or email API).
Step 3: Enable File Upload Handling
In the API setup section:
- Make sure your external API accepts file uploads.
- For the file field, use a key that matches what the API expects (e.g., file, attachment, etc.).
- Reference the form file field by name (e.g., your-file).
Example JSON Body (if using multipart/form-data):
{
“name”: “[your-name]”,
“email”: “[your-email]”,
“file”: “[your-file]”
}
If the API expects a base64 string, the Pro version supports converting the file content before sending.
Step 4: Test Your Integration
Submit a test form with a sample file. Check the external API or platform to ensure the file was received successfully. Look at the plugin’s log viewer to debug any issues—it will show the full request payload and response from the API.
Pro Tips for Better File Handling
- Limit file sizes to ensure smooth uploads.
- Restrict file types for security.
- Use secure endpoints (HTTPS) to protect file data.
- Consider file storage APIs like Dropbox, Google Drive, or AWS S3 if your primary platform doesn’t handle file uploads natively.
Final Thoughts
The ability to handle file uploads through Contact Form 7 and pass them directly to external APIs opens up a wide range of automation possibilities—from submitting resumes to syncing contracts and more.
With Contact Form to Any API, you can make file uploads part of a fully automated, secure, and professional workflow.