In this post, I will explain the file uploading and attachment feature introduced in Contact Form 7 1.9. If you are not familiar with Contact Form 7, please read the plugin homepage and FAQ first.
Summary
With this feature, you can allow your visitors to upload their files via your form, and then an email with attachments of the files is sent to you.
Please note that this feature uses the API of WordPress 2.7. So, in order to use it, you will need to upgrade your WordPress if you are using WordPress 2.6.x or older.
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 other types of form fields, you add a tag code into the Form area in the Contact Form 7 admin panel (Tools > Contact Form 7 in WordPress 2.7).
The tag of file upload feild is like this:
[file your-file]
As with other types of tags, ‘file’ means the type of tag, and ‘your-file’ means the name of the tag.
You can use several options with ‘file’ typed tags. To limit the max file size, use the ‘limit:’ option like this:
[file your-file limit:100000]
The unit of the digits is ‘byte.’ So ‘limit: 100000’ means that the limited max file size is approximately 100 kB.
To limit acceptable file types, use ‘filetypes’ option like this:
[file your-file filetypes:gif|png|jpg|jpeg]
List the file extensions after ‘filetypes,’ and separate them with ‘|’
(pipe) character when you set multiple file types.
You can also generate these tags with the Tag Generator, of course.

Set up file attachments with a mail
For file attachments, the new field File attachments is added in the Mail field set in the Contact Form 7 admin panel. To attach the uploaded files to the mail, put tags into this field as shown below.
File attachments:
[your-file]
As other tags used in the Mail field set, only the name (in this case, ‘your-file’) is needed. Don’t put the tag’s type or options.

If you have multiple files uploaded and want to attach them into an email, simply line them up like this:
File attachments:
[your-file][your-another-file]
(Japanese / 日本語)
Contact Form 7 1.9 にて追加されたファイルアップロードとメール添付のサポートについて説明します。Contact Form 7 自体をご存じない場合はプラグインのホームページおよび FAQ をまずご参照ください。
概要
この機能により、フォームにファイルアップロードの項目を追加して、そこからアップロードされたファイルをメールに添付して送ることが可能になります。
まずご注意いただきたいのは、この機能の使用には WordPress 2.7 の API が必要です。従って、もしいま WordPress 2.6.x 以前をお使いなら、まず先に WordPress をアップグレードしないとこの機能は使えません。
この機能のセットアップは2つのステップに分かれます。1) ファイルアップロード項目をフォームに追加すること、2) アップロードされたファイルを添付して送信するようにメールを設定すること、です。これから順を追って説明します。
ファイルアップロード項目のフォームへの追加
他のタイプのフォーム項目と同様ですが、タグをフォームのテキストエリアに追加することにより行います。フォームのテキストエリアは Contact Form 7 の管理パネル(WordPress 2.7 においてはツール > Contact Form 7 メニュー下)にあります。
ファイルアップロード項目のタグはこんな感じです:
[file your-file]
これも他のタイプのフォーム項目と同様、この場合の ‘file’ はこのタグのタイプを、’your-file’ はこのタグの名前をあらわします。
いくつかのオプションをこの ‘file’ タイプのタグに対して使えます。ファイルサイズの上限を指定したいなら ‘limit:’ オプションを以下のように使います:
[file your-file limit:100000]
数字はバイト単位なので、例えば ‘limit:100000′ とした場合の上限ファイルサイズは約 100 kB になります。
アップロードできるファイルの形式を制限したいなら、’filetypes:’ オプションを使います:
[file your-file filetypes:gif|png|jpg|jpeg]
‘filetypes:’ の後に続けて、アップロード可能なファイルの拡張子を並べます。複数指定する場合は ‘|’ で区切ってください。
もちろん手で入力しなくてもタグジェネレーターを使ってタグを生成することもできます。
メールへのファイル添付の設定
メールへのファイル添付のための項目(「ファイル添付:」)が Contact Form 7 管理パネルのメール項目群に追加されています。アップロードされたファイルをメールに添付するには、この項目に次のようにタグを追加します:
ファイル添付:
[your-file]
メール項目群での他のタグの使用と同様ですが、タグの名前(この場合だと ‘your-file’)だけが必要になります。タグのタイプやオプションを加えないでください。
複数のファイルをアップロードできるようにしていて、それらをまとめてメールに添付したい場合は、単純に複数並べれば可能です:
ファイル添付:
[your-file][your-another-file]
154 replies on “File uploading and attachment with Contact Form 7”
onmoraki4649 さん、こちらに説明があるのでこれを読んで設定してください。メールの方にもタグが必要です。
https://ideasilo.wordpress.com/2008/12/11/file-uploading-and-attachment-with-contact-form-7/comment-page-1/#more-243
それでもうまくいかない場合は日本語のサポートフォーラムの方に詳細書いて送ってください。
http://ja.forums.wordpress.org/forum/5
Hi,
Thank you for the plugin, it’s very nice and useful.
But I’m trying to use the file upload and it doesn’t work. I followed all the steps and I don’t understand why it won’t work…
Also, I’m using MailPress plugin and it looks like if I desactivate MailPress, Contact Form won’t send any e-mails… strange.
Do you have any idea why this won’t work?
As Mainguy, also can not successfully perform an upload using the forms generated.
See the poll of polldaddy and more than 60% of people say that failure has also…
Hi,
I having problem where I didn’t received any attachment but i can receive the mail.
need help
Wicked plugin, but I’m having problems with the file attachment too.
I can send & receive emails, but when I attach a file it says ‘Failed to upload file’…….. where am I going wrong?
I was having trouble with the file attachment then I re-read the directions and it’s working. Make sure once you add the ‘[file your-file]’ to the html you add ‘[your-file]’ to the mail portion. Don’t put [file your-file].
Hi,
I’m using wp 2.8.2 and contact form 7 2.0.1. I cant get the attache files. I’m getting this error:
Validation errors occurred. Please confirm the fields and submit it again.
I tryed with all extentions permision, but i’m still getting the error.
Could sone one help me?
Is there a video tutorial to apply the upload file feature?
Thanks for sharing this information. Helps out for sure. Keep up the good work.
Nice feature. I appreciate your contact form.
But there is a bug if file upload size is restricted by server (PHP file upload limit).
In my case, my server doesn’t accept files bigger than 2MB. I have set the file limit on CF7-settings to 1MB. If I have a file smaller than 1MB or between 1MB – 2MB everything works correct.
But if the file is bigger than 2MB, the result is “Your message was sent successfully. Thanks.” instead of an error message which should come up. The attachment is not attached.
hi there,
thanks for this really nice working plugin. works absolutely well for me, but i have 2 small problems with it:
1. i an contact form on one of my pages i give the user more than one upload box (e.g. 3) for uploading pictures so that he is able to decide how many pictures he wants to upload. now when the user wants to upload ONLY 2 pictures, he gets this error message: Uploading a file fails for PHP error.
How can I make the form work, so that the user can decide by himself how many pictures he wants to upload.
2. if users use a googlemail-adress in the contact form, they get a MAILER-DAEMON-Message back:
62.146.xxx.xx does not like recipient.
Remote host said: 554 5.7.1 : Sender address rejected: Access denied Giving up on 62.146.xxx.xx.
i would really appreciate it, if someone could give me a hint, on how to solve those problems.
@tzmc thanks. there was a bug in file uploading and I fixed it. Please try the Development Version:
http://wordpress.org/extend/plugins/contact-form-7/download/
@miyoshi:
problem 1 is solved: very cool !
though problem 2 is still an issue. but it seems to be a problem with my email and webserver host, so i have to take care of it myself.
thanks a lot for the quick and nice feedback. ;)
I was hoping the newest version of this plug-in would fix my uploading problem. You can upload and send just fine, but when the email is received I don’t get any attachments.
Sorry, here is the URL of the contact page
http://www.diglounge.net/contact/
Hey Matt,
I had the same problem before, so maybe I can help you.
Are you sure, that you have set up your contact form correctly (in the WP admin) ?
In the mailoptions for your contact form (where you type in the email-adress that the mail from the contact form is going to be sent to), you have to fill in the file-id into the attachments-field and is has to look like this [file-id1]. If you have more than one file leave blank space between the brackets like this: [file-id1] [file-id2].
Maybe this could help.
Cheers
Yes! That works. Thanks so much, don’t know how I missed that. I never saw that in the instructions.
I get this problem when I try to upload a file:
Failed to upload file
What do I do?
I get the same problem.
“Failed to upload file”. Validation errors occurred. Please confirm the fields and submit it again.
The directory is writeable and I have followed exactly as instructed above.
First, up thanks for the awesome plugin. Only complaint is that the file upload is not working for me as intended. I have implemented it here:
http://www.home-designing.com/suggest-us-a-design
When i try to submit after choosing a file, it keeps on showing the busy symbol and the mail never gets sent. But if i leave it blank the mail gets sent. (I have used updated the file attachment field as you have instructed)
Any ideas?
Has the limit of the attahment been set wrong probably?
While using [your-another-file], when you hit browse to select the files, Ctrl does not work. I can only upload one file at a time. Can that be fixed?
Thanks.
As a follow up to the Q above, are you supposed to make a new [your-another-file] tag first? Can it be generated like the rest?
Thanks.
Hi all.
If you can’t receive the attached files in your email via contactform7, you need to set correctly your form-code:
if in form-code there are
«[file your-file-247 limit:20000000 filetypes:zip|rar|txt|avi|jpg|jpeg|png|gif|exe]»
you need add into «File attachments:» field next text
«[your-file-247]»
That’s all :-)
Hi,
I get the same problem as Joakim and Peace.
“Failed to upload file. Error occurred.
Has anyone found the answer to this problem?
Did you watch the instructional video and follow the directions? It is pretty simple to do.
Maybe you have not adjusted the size of files properly or named it right like Andrey says above?
I didn’t watch the instruction video. Everything is working properly but every time I need to send the file. The problem arises when I don’t want to send any file, just the same message.
My settings in the adimn panel.
name
[text 1=”your-name” language=”*”][/text]
e-mail
[email* your-email]
subject
[text 1=”your-subject” language=”*”][/text]
file
[file file-510]
your message
[textarea your-message]
[submit “send”]
and I have File attachments: [file file-510]
Funny :) When I updated the plugin 7 2.0.4 problem with sending disappeared. But now it does not send attachments in @
Lo explico en español
A mi tampoco me funciono a la primera y me vine a esta pagina para averiguar como se debe hacer.
Crea el [file nombre-que-quieras] y colocalo dentro del form, pero abajo donde te pide el parametro de file attachment, colocalo asi: [nombre-que-quieras] y eso es todo.
Saludos
If I want to attach a standard file to each of the emails (like a log file) and that file is hosted on the website where wordpress is installed (so the user doesn’t need to upload anything) is this possible using this plugin?
If so – could you let me know how please?
Thanks
Martin
The upload works perfectly on my form. You have to make sure you put in the right name in the file attachment field.
Ditto Saikit. As long as the file attachment is named correctly, even the upgrade works well.
Good luck.
After update the plugin works correctly. :)
hello! I installed the latest version of the plugin 7 2.0.5 on WP 2.8.4 but file attachments do not arrive at destination.
Write here your settings
No way to make upload works. Anyone have a solution?
You should get it working if you followed the video. If not it could be the theme not allowing it probably.
Is it possible to use the file attachment feature to send a file to the user filling out the form.
i.e. The user fills out some information on the form (including their email) and an auto response email is sent back to the user with a file I have specified attached in the email?
If not, can someone recommend something that will do this for me? I have been searching for several weeks now and have not found something that will do this successfully (there have been a few others however none of them have worked as stated and all messages for help have gone unanswered).
Any help would be GREATLY appreciated!
Not sure if it is possible in WP. Just easire to subscribe to an Auto Responder. They capture the email for you and send out stuff if needed, like downloading etc.
This is great plugin :) I think you should include FTP upload option in this. Please do let me know what you think
Would be a great feature to have I think so too.
Just not sure if it can work with WP as it might need a higher access by the user to your back end server.
This plug-in is super great.
My only issue is that when someone tries to send a picture or file that is more than 1mb I get:
“Validation errors occurred. Please confirm the fields and submit it again.”
and i don’t have any type of size limits on my upload field. How do i fix this? Thank you.
When you fill the form out in your WP admin panel it allows you to set the size of files. I think default is something like 500KB. I have mine set to 2MB and am receiving files that size or less correctly. Hope that helps. Make sure [your-file limit] is set to 2000000 for 2MB. Hope that helps.
Hello,
I have a problem regarding the file upload. My html:
Upload your photo: *[file file-622 limit:2000000 filetypes:jpg|jpeg|png|gif]
My ‘File attachments’ in Mail section:
[file file-622]
I create a form with File upload (in my case image upload) and user tries to add whatever picture (size and file type are ok), it gets an error ‘Failed to Upload File’ in red below the upload field and error message with yellow borders which is taken from field labeled with “# Uploading a file fails for PHP error”
History:
I have had a previous version of this plugin 2.05 and it was working in 2009 September, but suddenly my server provider was bought by other one and all server data has moved to new one (I am using shared hosting, quite small plan). And this file upload stopped working. I have noticed that I was not receiving any filled forms during the week when exactly this moving appeared. So I disabled the file upload and the form was working. But… I need the pictures anyway and asking every form filler to send the picture by mail sound kinda absurd. So I decided to update plugin to new version today expecting the the file upload will work. No it dont. So I suspect that it is a problem of some server configuration.
Aha! I thought that my server doesn’t allow to upload the pictures and check the folder wp-content/uploads/wpcf7_uploads. It’s CHMOD is 777, so should work well. In the same folder appears .htaccess (CHMOD is also 777), which contains only one line:
“Deny from all”
WTF? :)
If I delete it, file upload still doesn’t work. Maybe plugin is not storring these files on the server… So I move on..
On the forum I found that moving back to 2.0 version of plugin makes it work. But maybe anybody can recommend what to do to fix it in current version?
Maybe anybody has faced what must be configured on the server that it would allow picture sending?
PS I have red almost every possible advice on the net, this is the last hope :(
Could it be that the security features on your new server are not allowing any pictures to be loaded onto it by your users? Just a thought.
Ed, sure. Maybe you have any idea how to check it?
By the way, for those for whome file upload is working – is this plugin uploading the files to wp-content/uploads/wpcf7_uploads ?
Ed, I have contacted my hosting provider. They have asked whether Plugin is using ‘phpmail’ function. What’s that? :) Yes or no?
I want to say yes. To be completely sure just take a look at the source code in the .php file to make sure.