0
votes

I'm having trouble using ColdFusion 9.0.0 fileUpload() cfscript function. I'm getting this error message:

"Variable FILEUPLOAD is undefined."

Here is my code:

result = fileUpload(application.uploadPath, "attachment", "application/*, image/*", "makeUnique");

As an alternate solution, I was able to get it to work with the suggestion here Script function for file upload in ColdFusion 9 .

The fileUpload() function works on my local desktop running ColdFusion 9.0.1. I curious if anyone has gotten it to work on ColdFusion 9.0.0.

thanx

2
How are you including the function definition into your application? If it's in a CFC, you'll have to reference it as cfcInstance.fileUpload(). If you embed the <cffunction> definition in the same template as you are calling it, then it should work by calling simply fileUpload(). - imthepitts
is there any reason why it's not upgraded to cf901? - Henry
It in a CFC and I'm using CFWheels framework. Here's what my create() looks like. public any function create(){ processlinks = model("ProcessLinks").new(params.processlinks); if (processlinks.save()){ if(params.attachment != ''){ result = fileUpload(application.uploadPath, "attachment", "application/*, image/*", "makeUnique"); if(result.fileWasSaved) { attachments = model(name="Attachments").new(attachment=result.serverFile, ProcessLinksID=processlinks.id); attachments.save(); } } } } - user752746
I've been waiting for the admin to update for some time now. Thought I see if anyone had any luck. - user752746

2 Answers

3
votes

From the docs for fileUpload() (always a good place to start with these sorts of questions):

History

ColdFusion 9.0.1: Added this function.

Which kinda explains why it doesn't work in CF9.0. To "make it work" you're gonna need to roll your own, or perhaps uploadFile() on cflib might be an option.

0
votes

One other thing to maybe note with FileUpload(), is that, unlike the cffile tag-based equivalent, it doesn't give you the option to specify a "mode" (e.g. 777). So when being run on a linux servers where permissions are restricted then you can encounter some strange behaviour!

I wonder if anyone else has encountered this? or has heard of a workaround?

FileUpload() Doc: http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSd160b5fdf5100e8f36f73035129d9e70a92-8000.html