Tip: How to add attachment fields
How can I add file attachment fields?
The attachment field can be used to allow users to attach a file upload from the form. You can add one or multiple attachments using the extra fields feature. The uploaded files will be sent as attachments with your email. Attachments are deleted from the server after the email is sent, unless you install the “Contact Form 7 to Database Extension“.
How to add extra form fields for file attachments:
To enable an attachment field, just add a new field on the Fields tab, then enter a field name such as “Attach Resume:”. Then, select the Field type: “attachment“. Then check if you want the field to be required or not. Click “Save Changes”.
How to set the attachment types and maximum size allowed:
On the ‘Fields’ tab, you can set the acceptable file types for the file attachment feature. Any file type not on this list will be rejected. Separate each file type with a comma character. example: doc,docx,pdf,txt,gif,jpg,jpeg,png
Set the acceptable maximum file size for the file attachment feature.
example: 1mb equals one Megabyte, 1kb equals one Kilobyte
Note: Maximum size is limited to available server resources and various PHP settings. Very few servers will accept more than 2mb. Sizes under 1mb will usually have best results. examples: 500kb, 800kb, 1mb, 1.5mb, 2mb Note: If you set the value higher than your server can handle, users will have problems uploading big files. The form can time out and may not even show an error.
Do not expect much success with any files over about 2M
Sadly, with HTTP POST, it is normal for there to be no graceful error when the upload fails, expect a white screen timeout when this happens.
Form POST reliability with large files is very limited because of the user’s upload speed is usually the slowest link. Time is one of the factors that causes the failure of large file uploading. Just because your server has large ‘upload_max_filesize’ and ‘post_max_size’ settings does not really mean you can expect success with large files.
The biggest obstacle to HTTP POST uploads is the fact that most broadband internet upload bandwidth is usually 10 times lower than the download bandwidth. This will easily cause server timeouts when trying to upload files bigger than 1-2M by HTTP POST. For this very reason, if you need to upload files bigger than 1-2M, you really need to use a FTP server or a large file hosting service.
If you’re having problems uploading large files but small files go through fine, here are some things to try:
– On the contact form edit settings page, make sure you’ve set “Attached files maximum size allowed” to an acceptable value. Settings 1mb or less will usually have best results. examples: 500kb, 800kb, 1mb, 1.5mb, 2mb. This is why the default setting is 1mb. Click ‘help’ next to this setting to see what your server reports it is capable of: “Your server will not allow uploading files larger than than: X”. The value for X can vary based on your PHP settings for upload_max_filesize and post_max_size.
– In php.ini, be sure you’ve set the the upload_max_filesize and post_max_size to be large enough to handle your upload.
– In your httpd.conf (if you’re using apache), check that the LimitRequestBody directive isn’t set too low (it’s optional, so it may not be there at all).
The ultimate solution for large files is to have your users send you large files with a large file hosting service.Do you need help?
Send us a Donation: