House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

cffile(upload) and cfc's

  << Previous Post |  RSS |  Tree View |  Sort Oldest First |  Subscribe to this Group Next >> 

cffile(upload) and cfc's

CFFILE Upload in a CFC Todd 04/23/2003 08:17 AM
I had the same exact problem a while ago! Angel Stewart 04/23/2003 08:10 AM
You can only specify a form scope variable in cffile - however - you can Todd Rafferty 04/23/2003 06:45 AM
I'm not sure exactly what you're trying to do, but I can upload via a cfc Simon Horwith 04/23/2003 02:35 AM
I believe you are right. This is to prevent malicious access to the client Tilbrook, Peter 04/23/2003 01:43 AM
I think you can only specify a form scope variable in cffile. Matthew Walker 04/23/2003 01:17 AM
Ok, curious if anyone has some insight. I'm having delimmas with cffile and Robby L. 04/23/2003 01:14 AM

04/23/2003 08:17 AM
Author: Todd Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:23351#117413 CFFILE Upload in a CFC I keep seeing people get tripped up over this, so here's what the deal is.  The biggest thing you have to remember about cffile's upload is that no matter what, the filefield <b>has</b> to be the name of the form field that you're trying to upload. Example: <cffile action="upload" filefield="form.something" destination="c:\"> Note the lack of pound signs.  That means that you're forcing cffile to go look for form.something and grab the data stream out of it. So, what do you have to do if you put it in a CFC?  You can't pass the datastream into a CFC (you can, but that's not the correct way to do it).  You have to pass the name of the file field into the cfc instead. Example CFC: <cfcomponent name="fileio"> <cffunction name="fileUpload" access="public" returntype="struct"> <cfargument name="fileField" required="true" type="string"> <cfargument name="destination" required="true" type="string"> <cffile action="upload" filefield="#arguments.fileField#" destination="#arguments.destination#"> </cffunction> </cfcomponent> Not the pound signs around arguments.fileField.  Why?  Because you're evaluating the value of arguments.fileField which is actually a string: 'form.something'.  Example usage would be: <cfscript> fileObj = createObject('component','fileio'); fileObj.fileUpload('form.something','c:\'); </cfscript> HTH, ~Todd At 08:07 AM 4/23/2003 -0400, you wrote: >I had the same exact problem a while ago! > >Didn't get a fix for it from the list either actually. > >It would seem to be a bug. > >-Gel ---------- Todd Rafferty (todd@web-rat.com) - http://www.web-rat.com/ Team Macromedia Volunteer for ColdFusion http://www.macromedia.com/support/forums/team_macromedia/ http://www.devmx.com/ ----------
04/23/2003 08:10 AM
Author: Angel Stewart Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:23351#117412 I had the same exact problem a while ago! Didn't get a fix for it from the list either actually. It would seem to be a bug. -Gel
04/23/2003 06:45 AM
Author: Todd Rafferty Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:23351#117410 You can only specify a form scope variable in cffile - however - you can pass the 'name' of that form via argument. Example! ohfile('c:\','form.whatever');   <cffunction name="ohfile" access="public" returntype="any">          <cfargument name="thepath" type="any" required="true" />          <cfargument name="thefield" type="any" required="true" />          <cffile action="upload" filefield="#rguments.thefield# destination="#ExpandPath('arguments.thepath')#">          <cfreturn cffile> </cffunction> HTH, ~Todd At 05:14 PM 4/23/2003 +1200, you wrote: ----- Excess quoted text cut - see Original Post for more -----
04/23/2003 02:35 AM
Author: Simon Horwith Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:23351#117399 I'm not sure exactly what you're trying to do, but I can upload via a cfc with the following: the form file: <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <form action="my_action_page.cfm" method="post" enctype="multipart/form-data"> File: <input type="file" name="aFile"><br> <input type="submit" value="Upload a File"> </form> </body> </html> the component: <cfcomponent displayName="Upload Foo">      <cffunction name="uploadFoo" access="public" returnType="boolean" output="false">     <cfargument name="theFile" type="any">     <!--- uploadFoo body --->     <cfset var retVal = true>   <cftry>     <cffile action="upload" filefield="aFile" destination="C:\mypath\uploadTest\">   <cfcatch>     <cfset retVal = false>     <cfrethrow>   </cfcatch>   </cftry>     <cfreturn retVal>   </cffunction> </cfcomponent> the action page: <cfinvoke component="dot_path_to_my_cfc_file" method="uploadFoo" returnvariable="uploadFooRet"> <cfinvokeargument name="theFile" value="#form.aFile#"> </cfinvoke> ~Simon Simon Horwith Macromedia Certified Instructor Certified Advanced ColdFusion MX Developer Certified Flash MX Developer CFDJList - List Administrator Fig Leaf Software 1400 16th St NW, # 220 Washington DC 20036 202.797.6570 (direct line) http://www.figleaf.com I believe you are right. This is to prevent malicious access to the client machine. Instead they must manually specify a file to be uploaded to the CF server. >> I think you can only specify a form scope variable in cffile. ********************************************************************** The information contained in this e-mail, and any attachments to it, is intended for the use of the addressee and is confidential. If you are not the intended recipient you must not use, disclose, read, forward, copy or retain any of the information. If you have received this e-mail in error, please delete it and notify the sender by return e-mail or telephone. The Commonwealth does not warrant that any attachments are free from viruses or any other defects. You assume all liability for any loss, damage or other consequences which may arise from opening or using the attachments. **************************************************************************** *******
04/23/2003 01:43 AM
Author: Tilbrook, Peter Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:23351#117397 I believe you are right. This is to prevent malicious access to the client machine. Instead they must manually specify a file to be uploaded to the CF server. >> I think you can only specify a form scope variable in cffile. ********************************************************************** The information contained in this e-mail, and any attachments to it, is intended for the use of the addressee and is confidential. If you are not the intended recipient you must not use, disclose, read, forward, copy or retain any of the information. If you have received this e-mail in error, please delete it and notify the sender by return e-mail or telephone. The Commonwealth does not warrant that any attachments are free from viruses or any other defects. You assume all liability for any loss, damage or other consequences which may arise from opening or using the attachments. ***********************************************************************************
04/23/2003 01:17 AM
Author: Matthew Walker Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:23351#117396 I think you can only specify a form scope variable in cffile. ----- Excess quoted text cut - see Original Post for more -----
04/23/2003 01:14 AM
Author: Robby L. Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:23351#117395 Ok, curious if anyone has some insight. I'm having delimmas with cffile and a cfc. Basically I am using cffile in my base cfc so I can call on demand for a project I'm working with. But everything I seem to do causes cf to bail. I've Simplified the function down to the nth degree hoping to get it to work, but it for some reason still kicks out on me. <cffunction name="ohfile" access="public" returntype="any">     <cfargument name="thepath" type="any" required="true" />     <cfargument name="thefield" type="any" required="true" />     <cffile action="upload" filefield="arguments.thefield" destination="#ExpandPath('arguments.thepath')#">     <cfreturn cffile>   </cffunction> The form field "FILE" did not contain a file. Is the lovely error I get.( Its the same error I would get if I had #'s in the filefield on just a basic action page.) If I do a cfdump on the variables I get C:\CFusionMX\runtime\servers\default\SERVER-INF\temp\wwwroot-tmp\neotmp4204.tmp or a variant on it (#'s of neotmp could be different). Stan Winchester had a similar post that I found in the archives, though I couldn't see a fix or a reasoning. Angel Stewart Subject: CFFILE uploading within a CFC, with formfield as a CFC Argument. Did as well, . though again no fix or reasoning. I do, to a point understand what the whole "tmp" thing is, . but when I'm passing to the cfc as an argument it just hasnt worked. my entype is correct, (though obviously if it's set to text/ or /application it's dumping correctly - but can't be used in cffile) The behaviour is sporatic, . happens here and there, but not everywhere type of thing. More often does than doesnt. Anyone have a clue on why it's doing it? or what I can do to avoid it? I don't have a problem using a cfm page just for the uploading, just blows leaving out one bit. I've also tried uploading without the use of the function that is calling it. But anytime it's in a function it's kicking., Sorry for the long post,. just wanted to give all *I* knew. Thanks again , Robby _________________________________________________________________ Help STOP SPAM with the new MSN 8 and get 2 months FREE*   http://join.msn.com/?page=features/junkmail
<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

May 24, 2012

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
     1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31     

Designer, Developer and mobile workflow conference