passing form to cfc using javascript and cfajaxproxy
Hello,
environment: cf8 (win); no db;
I'm trying to pass the form scoped refernce to a method that uses cffile to upload a file. My understanding with cffile is that the form field needs to be passed to the method as scoped as a form struct in order to get the file to upload (otherwise i get a enctype error). Is it possible to pass the form through the javascript object reference to the cfc? (serializing the form doesn't seem to work)
sample code;
<cfajaxproxy cfc="name" jsclassname="jsNews" />
...
<script>
function fnSetNews(id){
var cfc = new jsNews();
file=$('#file_'+id).val();---not quite sure how to call; I would prefer to keep the script on a .js file (no fancy cf referencing)
var response=cfc.setImage(file);
/*file is a valid form path selected on a "file" field of a form.*/
}
</script>
...
<form id="unique" class="frmUpload">
<input type="file" name="unique" id="unique" />
<input type="submit" value="go" />
</form>
...
listener (calls the js function upon submit)
$('.frmUpload').livequery('submit',function(event){fnSetNews(this.id);return false;});
...
cfc code:
<cffunction name="setImage" access="package" output="true" returntype="Any">
<cfargument name="fileField">
<cffile action="upload" filefield="#ARGUMENTS.fileField#" destination="validPath" nameconflict="overwrite">
</cffunction>
any help is greatly appreciated-dj
