2 Replies Latest reply on Apr 5, 2007 10:39 AM by Newsgroup_User

    CFC File Upload Error in Fusebox 4

    simonbingham
      Hello,

      I have written a CFC which uploads (or is meant to upload) a file to the server using CFFILE. However, I am getting the following error message when attempting to upload the file:

      "The form field "C:\CFusionMX7\runtime\servers\coldfusion\SERVER-INF\temp\wwwroot-tmp\neotmp41361.tmp" did not contain a file."

      My code for invoking the CFC is:

      <invoke object="application.utility" methodcall="importFile(myFusebox.importFilePath,csvFile,'text/csv, text/comma-separated-values')" returnvariable="importFile" />

      My CFC code is:

      <cfcomponent displayname="Utility" hint="Code for utility functions" output="no">
      <!--- Import a file --->
      <cffunction name="importFile" access="public" returntype="struct" hint="Upload import file">
      <cfargument name="importFilePath" type="string" required="yes" hint="Absolute path to import directory" />
      <cfargument name="importFileName" type="any" required="yes" hint="Name of the file to be imported" />
      <cfargument name="acceptedMimeTypes" type="any" required="no" hint="Comma separated list of mime types" />

      <cffile action="upload" destination="#arguments.importFilePath#" filefield="#arguments.importFileName#" nameconflict="overwrite" accept="#arguments.acceptedMimeTypes#">

      <cfscript>
      importFile=StructNew();

      StructInsert(importFile,"attemptedServerFile",cffile.attemptedServerFile);
      StructInsert(importFile,"clientDirectory",cffile.clientDirectory);
      StructInsert(importFile,"clientFile",cffile.clientFile);
      StructInsert(importFile,"clientFileExt",cffile.clientFileExt);
      StructInsert(importFile,"clientFileName",cffile.clientFileName);
      StructInsert(importFile,"contentSubType",cffile.contentSubType);
      StructInsert(importFile,"contentType",cffile.contentType);
      StructInsert(importFile,"dateLastAccessed",cffile.dateLastAccessed);
      StructInsert(importFile,"fileExisted",cffile.fileExisted);
      StructInsert(importFile,"fileSize",cffile.fileSize);
      StructInsert(importFile,"fileWasAppended",cffile.fileWasAppended);
      StructInsert(importFile,"fileWasOverwritten",cffile.fileWasOverwritten);
      StructInsert(importFile,"fileWasRenamed",cffile.fileWasRenamed);
      StructInsert(importFile,"fileWasSaved",cffile.fileWasSaved);
      StructInsert(importFile,"oldFileSize",cffile.oldFileSize);
      StructInsert(importFile,"serverDirectory",cffile.serverDirectory);
      StructInsert(importFile,"serverFile",cffile.serverFile);
      StructInsert(importFile,"serverFileExt",cffile.serverFileExt);
      StructInsert(importFile,"serverFileName",cffile.serverFileName);
      StructInsert(importFile,"timeCreated",cffile.timeCreated);
      StructInsert(importFile,"timeLastModified",cffile.timeLastModified);
      </cfscript>

      <cfreturn importFile />
      </cffunction>
      </cfcomponent>

      How do I correctly pass the name of the form field containing the file to the CFFILE tag?

      Many thanks in advance for your help,

      Simon