Greg's Blog

helping me remember what I figure out

File Uploading via CFC

| Comments

I have stumbled over this in the past as well and since there was a thread on this topic on CFCDev, I thought I’d detail the work around here. A good solution comes courtesy of Todd’s site: rather than passing in the data stream you pass in a reference (a string like “form.fileField”) to the form field that is doing the upload. By using the hash signs around the form field argument in the fileField attribute of <cffile> you force the tag to evaluate the reference to the form scope. Todd has a detailed explanation about what goes on and how to make it work. However as a few people pointed out the <cffile> is still referencing the form scope directly, which then breaks encapsulation (again just a warning if encapsulation is important to your approach).