CFv4 File uploads

I get a 500 Error when I upload a file

There are two likely causes of 500 Errors on file uploads - both of them related to servers settings. One is the upload_max_filesize in the php.ini file; the other an Apache MaxRequestLen setting.

Multiple file uploads from an iPad/iPhone don't work

It looks as if the iPad and probably the iPhone gives the same file name to all file uploads, for images this is image.jpg. If you have more than one file upload in the same form then only one file will be uploaded because of this. Here is a workaround to avoid this problem. 

How can I zip uploaded files?

If the form includes large files or several files that you want to keep together it may help to add them to a 'zip' archive. This FAQ has code that will let you do that and then save and / or email the zipped file.

How do I show a 'loading' message when the form submits?

With a little work you can attach a loader image to the validation 'onSuccess' event.

How can I attach a file I have created to an email?

This request came from a user whose form created a CSV file which needed to be emailed. The way to do it is to add an entry into the $form->files array that the Email action can then read in the same way as it can an uploaded file.

I've got a JFolder::create error message

When developing forms with file uploads you will sometimes get error messages referring to JFolder or JFile. These are usually because the permissions are not correctly set on the upload folder.

How can I link to an uploaded file?

Sometimes uploaded files are too large to attach and email so it is more helpful to add a link; or you may want to show an image file to confirm what has been up loaded. This FAQ shows you how to build links to use in Email templates and Thank You Page actions.

How can I validate and debug file uploads?

ChronoForms has two built-in ways to validate file uploads. You must specify the type or types of file that you allow, and the maximum and minimum size of uploads. 

How can I add a file upload to my form?

A file upload will add an input to your form that lets users select a file to be uploaded to the site server. ChronoForms lets you specify the allowable file types and sizes. This video shows you a simple example.

How can I attach uploaded files to an email?

ChronoForms does not link uploaded files to emails automatically. You need to add the input names of the file upload elements to the Attachments Fields Name box in the Email action.

How can I delete old file uploads?

If your form includes image uploads you may find after time that they are taking up too much space and older files need to be deleted. Here's a code snippet to do that:

How can I edit uploaded files in a form?

It isn't useful to redisplay the value of file inputs in an edit form as there is no way of knowing the path to the file on the user's computer and so the value is incomplete. Because of this most browsers won't allow it.

How can I upload files under some user's folder

When the files are uploaded we would like to put them into their own user folder under the upload folder.