Skip to content

I tried to upload a file via a form and I get an error stating that my form file did not contain a file, how can I fix this?

thofrey edited this page Jul 23, 2013 · 2 revisions

This inevitably happens to all newcomers to Mach-II. As you know, the event object in Mach-II contains all the input parameters from the URL and the Form scopes. When you use the getArg() function, you are actually dipping into the accumulated values. This provides a nice abstraction for those parameters because we don't care whether the parameter came in via post or get, we just need to access the value. Also, there are some handy offerings such as setting a default value, testing for the existence of a parameter, etc.

This is all well and good until you need to upload a file. The file upload routine in ColdFusion requires the actual name of the form field, not a reference to the contents. Thus, use the actual name, not the arguments.event.getArg() syntax.

The documentation on cffile is quite good. Have a read at the ColdFusion documentation for CFFile mode=upload for more details.

If your problem is not fixed by using the explicit name of the form field, you may want to check your form tag for the proper enctype attribute. enctype="multipart/form-data"

Back to FAQs

Clone this wiki locally