You can include a File Tag in a contact form to allow a user to send you a file attachment via the contact form. In order to use a File Tag, you must:
- Add a File Tag to your contact form on the Form Tab of the Edit Contact Form page.
- Add a File Tag to the contact form email on the Mail Tab of the Edit Contact Form page for the contact form you are editing.
A File Tag can be either optional (file) or required (file*).
- id:id – adds an id attribute to the tag
- class:class – adds a class attribute to the tag
- limit:size – sets the maximum file size accepted as an integer with an optional unit suffix. If you omit a unit suffix, bytes are assumed. You may also use “kb” or “mb.” For example:
[file my-file limit:1mb]
- filetypes:filetype1|filetype2|filetype3… – a pipe-separated (|) list of acceptable file types; e.g.:
[file my-file filetypes:jpg|jpeg|png]
If you do not specify the limit or filetypes options, Contact Form Redux sets the following defaults:
- limit – 1 MB
- filetypes – jpg, jpeg, png, gif, pdf, doc, docx, ppt, pptx, odt, avi, ogg, m4a, mov, mp3, mp4, mpg, wav, and wmv
Attaching the File(s) to the Email
Attaching the file(s) to the email sent when a contact form is submitted is accomplished by adding a Mail Tag in the File Attachments Section on the Mail Tab for the form using the same name you used for the Form Tag:
To attach multiple files, simply add the file Mail Tags consecutively in the File Attachments Section:
Attaching Local Files
You can also attach local files from within the /wp-content folder and its subfolders by adding the path on a new line in the File Attachments Section of the Mail Tab:
File Upload Process
When a user submits a contact form containing a file, the file is checked for type and size, then copied to a temporary folder, /wp-content/uploads/cfredux_uploads. (Note: the path may be different if you changed the uploads folder for your WordPress installation.)
If file permissions prevent the folder from being created, file uploads may fail. If this occurs, as a first troubleshooting step, you can manually create the folder.
The path to the temporary folder used for file uploads can be changed by setting the following in your wp-config.php:
Make sure that the temporary folder used for file uploads is present and is writable, or file attachments will not work.