In this post, I will explain the file uploading and attachment feature of Contact Form 7. With this feature, you can allow your users to upload their files via your form, and then an email with attachments of the files is sent to you.
To set up, two steps are needed: 1) Add file uploading fields in your form, 2) Set up your mail settings to attach the uploaded files. The two steps will be explained in the rest of this post.
Adding file uploading fields in your form
Like for other types of form fields, Contact Form 7 provides form tags for file uploading fields (<input type="file"> in HTML): file and file*. file* is a required field and requires the user to upload a file.
| Option | Examples | Description |
|---|---|---|
| id:(id) | id:foo |
id attribute value of the input element. |
| class:(class) | class:bar |
class attribute value of the input element. To set two or more classes, you can use multiple class: option, like [file your-file class:y2008 class:m01 class:d01]. |
| filetypes:(filetypes) | filetypes:gif|png|jpg|jpeg |
Acceptable file types. List the file extensions after filetypes:, and separate them with ‘|’ (pipe) character when you set multiple file types. |
| limit:(num) | limit:1048576limit:1024kblimit:1mb |
Limit the max file size acceptable. You can use kb (kilo byte) or mb (mega byte) suffix optionally. If you omit suffix, the number means bytes. Note that you can’t use a decimal point in it (i.e., like this: [file your-file limit:1.5mb]) and it will be ignored if it exists. |
Example:
[file your-file filetypes:pdf|txt limit:2mb]
Contact Form 7 applies default restrictions for file type and file size when you do not set the filetypes: and limit: (file size) options explicitly. Default acceptable file types (extensions) are: jpg, jpeg, png, gif, pdf, doc, docx, ppt, pptx, odt, avi, ogg, m4a, mov, mp3, mp4, mpg, wav, and wmv. Default acceptable file size is 1 MB (1048576 bytes).
Setting up file attachments with a mail
To attach the uploaded files to the mail, put mail tags corresponding to form tags for file uploading fields into ‘File attachments’ field as shown below.

In this example, the form tag for the file uploading field is:
[file your-file filetypes:pdf]
Therefore, the corresponding mail tag to this is:
[your-file]
Note that what you’re required to put in the ‘File attachments’ field is [your-file], not [file your-file filetypes:pdf].
If you have multiple files uploaded and want to attach them into an email, simply line them up in the ‘File attachments’ field like this:
[your-file][your-another-file]
How your uploaded files are managed
After a user uploads a file through your contact form, Contact Form 7 checks to see if: 1.) Any PHP errors have occurred; 2.) the file type and file size are valid; and then, if the check turns out okay, Contact Form 7 moves the uploaded file to a temporary folder. At this point, Contact Form 7 attaches the file to the mail and sends it. After these procedures, Contact Form 7 then removes the file from the temporary folder.
The location of the temporary folder depends upon your settings in WordPress. Open the Settings > Miscellaneous menu, and check the setting for Store uploads in this folder field. The default is wp-content/uploads. Normally, Contact Form 7 creates a wpcf7_uploads folder in this location and uses it as the temporary folder for any uploaded files.

This folder is created automatically, but sometimes it can fail. The most possible reason for this is that the parent folder doesn’t have sufficient writing permissions. In such cases, you can change the permissions or create a folder manually.
You can also change the path of the temporary folder by setting the WPCF7_UPLOADS_TMP_DIR constant in your wp-config.php like this:
define( 'WPCF7_UPLOADS_TMP_DIR', '/your/file/path' );
If WPCF7_UPLOADS_TMP_DIR is defined, this directory is used as the temporary folder instead.
Make certain your temporary folder for uploaded files exists and is writable. Otherwise, all file uploading will fail.
English
Japanese 

I’d like to allow people to send me files up to 1024mb in size. How can I change that?
1024mb? Too large for uploading and attaching to mails. Burn it a DVD and ship it, or use Dropbox.
Really? How can get at least max file size? I couldn’t attach anything over 2mbs, even changing and specifying the limits.
How would I go about allowing users to send large files then?
I know AwkwardFamilyPhotos.com has a form that allows up to 1GB: http://awkwardfamilyphotos.com/send-us-your-photos/
Did they make their own?
It depends on your PHP setting as well.
Can I attach a file already uploaded to my site? If yes how?
Thanks.
No, you can’t. Why not write URL of the file in the mail body?
I would’ve preferred to include the actual file but I guess I’ll have to make do with just giving them a link…
I guess if i really want it I’ll just have to add that functionality myself…
Hi.
I like doing everything correctly, but the files are not sent.
From simple messages without the files no problem.
Code:
File upload (required)
[file* your-file]
File upload 2
[file your-file]
File upload 3
[file your-file]
Mail code:
File attachments:
[your-file][your-another-file]
Thanks.
No, it’s incorrect. It should be:
Code:
File upload (required)
[file* your-file-1]
File upload 2
[file your-file-2]
File upload 3
[file your-file-3]
Mail code:
File attachments:
[your-file-1][your-file-2][your-file-3]
or like that. Read basic tutorials first.
Getting Started with Contact Form 7
Tag Syntax
I have an existing, non-Wordpress PHP form that uploads up to 2 files on a single form. On the back-end my form processor program uses PHP to do things like dynamically assigning unique file names and time stamping those uploaded files (it also takes all the incoming fields from the contact form and dynamically creates a .TXT file with a similar time stamp in the filename).
I tried to implement a Wordpress version of that form using EXEC-PHP but so far I am running into (hopefully) minor issues – such as not seeing the incoming $_POST fields. Before I continue using only EXEC-PHP, I was wondering if I would be able to do my form in WP using Contact 7 (and perhaps using EXEC-PHP for my special form processing logic).
Can I use Contact 7 to create a form that would be able to manipulate the incoming form data and create dynamic files from the uploaded files?
I am looking for something like this but I want users to be able to upload files to my server and then link to them.
Say I set the upload directory to BBOTA and once the files are uploaded the person could create a link of http://www.website.com\bbota\filename.ext
Is this possible?
It’s not possible with the default functions of Contact Form 7, and is possible to be insecure.
Very helpful documentation. Thanks for offering a great free product.
I’m testing our your plug-in, which is great btw, but in file uploads (i have multiple), doesn’t seem like I can delete the file directory once i inserted a file in there.
Is it possible to keep the files in the temporary directory and only send the names of them by eMail ?
No. It can cause security issues.
OK. I understand why. Thanks.
First of all, thank you for this great plugin! I do have a quick question about file attachments.
Does Contact Form 7 support the attachment of file types other than the included by default (jpg, jpeg, png, gif, pdf, doc, docx, ppt, pptx, odt, avi, ogg, m4a, mov, mp3, mp4, mpg, wav, and wmv)?
I am having trouble using the contact form to attach zip files, even when I add it as an acceptable file type.
Yes, you can upload & attach zip files if you set up correctly.
Could you provide an example of the proper syntax for a file attachment that allows a pdf and a zip file only. Thank you.
thanks alot.. attachments are now working for me after following your instructions.
Love the plug-in for the typical contact form functionality. However, and additionally, we have a new need; to allow people to upload a file(s). Once the file is uploaded to a directory on the server, an email is generated to a predetermined email address, with a link to the file(s) that were uploaded.
From my basic understanding from the documentation, this is possible. However, the inquiries and responses in this forum seem to contradict this.
Is what we’re looking to do possible with Contact Form 7?
It is not possible.
I was trying to get the file attachment to work, I placed [file* your-file] in the form, and [file* your-file] in the field under file attachments section of the “Mail” section.
The email message was coming through, but the attachment was not. I made sure the file permissions were set to write, but the mail message would come through and the attachment still would not. I then changed the code in the file attachments field in the “mail” section to just “[your-file]” while leaving the [file* your-file] in the “form section” and it works great.
I don’t know if this will help others, but I thought I’d put it out there.
Example:
[file your-file filetypes:pdf|zip]It’s easy to use the tag generator (right pane to the ‘Form’ field) to get it.