How does one upload a file from flex to a cfc
How does one upload a file from flex to a cfc? Can you do the file upload via remote object? I usually do uploads cia cfm but prefer the asnc capabilities of remote object calls.
How does one upload a file from flex to a cfc? Can you do the file upload via remote object? I usually do uploads cia cfm but prefer the asnc capabilities of remote object calls.
Hi,
The issue here is myFile. For flex we need to pass this name as paramenter becuase it's not html form item like:
<cfcomponent>
<cffunction name="uploadFile" access="remote" output="false" returntype="void">
<cfargument name="file" required="Yes" type="any">
<cffile action="upload" filefield="#arguments.file#" destination="C:\temp\" nameconflict="makeunique">
</cffunction>
</cfcomponent>
From flex I'm getting the file using fileReference like:
private function browseAndUpload():void
{
fileReference = new FileReference();
fileReference.addEventListener(Event.SELECT,fileReference_Select);
fileReference.addEventListener(Event.CANCEL,fileReference_Cancel);
fileReference.browse();
}
private function fileReference_Select(event:Event):void
{
fileReference.addEventListener(ProgressEvent.PROGRESS,fileReference_Progress);
fileReference.addEventListener(Event.COMPLETE,fileReference_Complete);
fileReference.addEventListener(IOErrorEvent.IO_ERROR,onLoadError);
//fileReference.upload(request);
fileName = fileReference.name;
myFile.htmlText = fileReference.name;
SM_RO.importNSA();
}
filerReference have an upload method to upload the file but I can't use that becuase I need to process my upload with my cfc.
I'm getting an error:
Failed to import the file. The cffile action="upload" requires forms to use enctype="multipart/form-data". Please also make sure the file is not open.
I can't find the way to setup the enctype becuase again i can have html form items in flex, or I can?
Thanks
Johnny
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.