1 Reply Latest reply on Aug 30, 2006 6:20 AM by Dan Bracuk

    how to encorporate cffile within cfc?

    tibs75 Level 1
      Guys,

      I need to submit a form which has a file field within, the action on the form is action="cfc/docs_class.cfc?method=upload" like so:

      <form id="oForm" name="oForm" action="cfc/doc_class.cfc?method=upload" enctype="multipart/form-data" method="post">
      <input type="file" id="txtFile" nmae="txtFile">
      <input type="submit" value="Send">

      </form>

      within the cfc i have

      <!--- Function(): To upload binary file --->
      <cffunction returntype="string" name="upload" output="false" displayname="" access="remote">
      <cfargument name="txtFile" required="yes" type="any" />

      <!--- local variables in function --->
      <cfset var ostruct = StructNew() />
      <cfset ostruct.ERRCODE = 0 />
      <cfset ostruct.ERRMSG = "" />
      <cfset ostruct.RESULT = StructNew() />

      <cftry>
      <cffile action="upload" fileField="txtFile" destination="#application.settingsCFC.getMediaServerUNC()#\" nameConflict="MakeUnique" />

      <cfset ostruct.RESULT = cffile /> <!--- The result is a cffile object --->

      <cfcatch type="Any">
      <cfset ostruct.ERRCODE = 1 />
      <cfset ostruct.ERRMSG = cfcatch.message />
      </cfcatch>
      </cftry>

      <cfwddx action="CFML2WDDX" input="#ostruct#" output="ostruct" />
      <cfreturn ostruct />

      </cffunction>

      I'm getting a internal server error 500. Can anyone help?

      - 1 puppy