Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFHTTP tag 1

Status
Not open for further replies.

Silvano

Programmer
Jul 16, 2001
386
US
this is textbook example as how to use http tag; however, it reports error: "The form field specified in the CFFILE tag (FILEVAR) does not contain an uploaded file... "

<cfhttp method=&quot;POST&quot;
URL=&quot; <cfhttpparam type=&quot;file&quot;
name=&quot;Filevar&quot;
file=&quot;c:temp\120222154.gif&quot;>
</cfhttp>

<cffile action=&quot;upload&quot;
nameconflict=&quot;overwrite&quot;
filefield=&quot;Filevar&quot;
destination=&quot;C:\Inetpub\
gimme some light, please Sylvano
dsylvano@hotmail.com
 
You need to set your URL in CFHTTP to a cfm page that does the file uploading, not to the img file.

I'm not exaclty sure what you're trying to accomplish here, but the way the scripts are written, you'd need to seperate them into 2 cfm files. For demonstrations sake, I'm showing them separated as script1.cfm and script2.cfm.

[COLOR=666666]<!--- script1.cfm --->[/color]
<cfhttp method=&quot;POST&quot;
URL=&quot;>

<cfhttpparam type=&quot;file&quot;
name=&quot;Filevar&quot;
file=&quot;c:temp\120222154.gif&quot;>

</cfhttp>

[COLOR=666666]<!--- script2.cfm --->[/color]
<cffile action=&quot;upload&quot;
nameconflict=&quot;overwrite&quot;
filefield=&quot;Filevar&quot;
destination=&quot;C:\Inetpub\wwwroot\120222154.gif&quot;>
- tleish
 
I am trying to upload a file by using cfhttp tag;


<!--- testpost.cfm --->
<cfhttp method=&quot;POST&quot;
file=&quot;112668895.jpg&quot;
path=&quot;C:\Inetpub\ URL=&quot;
<cfhttpparam type=&quot;file&quot;
name=&quot;Filevar&quot;
file=&quot;C:\Inetpub\
</cfhttp>

<CFLOCATION URL=&quot;test.cfm&quot; addtoken=&quot;No&quot;>



<!--- test.cfm --->
<cffile action=&quot;upload&quot;
nameconflict=&quot;overwrite&quot;
filefield=&quot;Filevar&quot;
destination=&quot;C:\Inetpub\

error when test.cfm is executed: &quot;The form field specified in the CFFILE tag (FILEVAR) does not contain an uploaded file... &quot;
Sylvano
dsylvano@hotmail.com
 
You don't need to use the <CFLOCATION> tag to make this work. Delete the following and the script should work fine.

[COLOR=666666]<!--- testpost.cfm --->[/color]
<cfhttp method=&quot;POST&quot;
file=&quot;112668895.jpg&quot;
path=&quot;C:\Inetpub\wwwroot\_theSite\storage\&quot;
URL=&quot;>


<cfhttpparam type=&quot;file&quot;
name=&quot;Filevar&quot;
file=&quot;C:\Inetpub\wwwroot\_theSite\storage\112668895.jpg&quot;>


</cfhttp>

<CFLOCATION URL=&quot;test.cfm&quot; addtoken=&quot;No&quot;>



[COLOR=666666]<!--- test.cfm --->[/color]
<cffile action=&quot;upload&quot;
nameconflict=&quot;overwrite&quot;
filefield=&quot;Filevar&quot;
destination=&quot;C:\Inetpub\wwwroot\120222154.gif&quot;>
- tleish
 
that is exactly my problem here: I have tried so many different ways and none is working and I just can't see why?

I tried what you are suggesting here and still does't work; hmpf...
when I try to access test.cfm, it still returns this error:
&quot;The form field specified in the CFFILE tag (FILEVAR) does not contain an uploaded file...&quot;

everything else is working fine...

thanks for your help here... Sylvano
dsylvano@hotmail.com
 
The way you set it up, the only way you should be accessing going to the actual page test.cfm is by submitting a form. CFHTTP simulates submitting a form, but it won't pass the FORM variables if you go from a CFHTTP page to a CFM page.

I think you may be going about it all wrong. What type of app are you trying to create.

FYI, this will turn the errors off on the test.cfm page:

[COLOR=666666]<!--- test.cfm --->[/color]
<CFIF IsDefined(&quot;FORM.Filevar&quot;)>
<cffile action=&quot;upload&quot;
nameconflict=&quot;overwrite&quot;
filefield=&quot;Filevar&quot;
destination=&quot;C:\Inetpub\wwwroot\120222154.gif&quot;>

</CFIF>
- tleish
 
thanks tleish, I promise that if we solve this you'll get a star from me :)

here is how I see this situation:
-on testpost.cfm file, this code is used to make 112668895.jpg file available to the server:

<!--- testpost.cfm --->
<cfhttp method=&quot;POST&quot;
URL=&quot; <cfhttpparam type=&quot;file&quot;
name=&quot;Filevar&quot;
file=&quot;C:\Inetpub\</cfhttp>

question here: my undersdtanding is that the url attribute specifies the file (test.cfm) where posted file will be used (112668895.jpg)

my literature tells me that all that I need to access posted file is cffile with upload action attribute therefore, on the test.cfm all needed code is:

<!---test.cfm --->
<cffile action=&quot;upload&quot;
nameconflict=&quot;overwrite&quot;
filefield=&quot;filevar&quot;
destination=&quot;C:\Inetpub\ attributes=&quot;normal&quot;>


the error tells me that the specified form field does not contain an uploaded file

what exactly is missing here? how am I to make 112668895.jpg file available for upload in the test.cfm file?
Sylvano
dsylvano@hotmail.com
 
In the case of these 2 scripts, you shouldn't even be opening test.cfm in you're browser. But, to ensure that you checking for errors, add this to testpost.cfm

[COLOR=666666]<!--- testpost.cfm --->[/color]
<cfhttp method=&quot;POST&quot;
URL=&quot;;>

<cfhttpparam type=&quot;file&quot;
name=&quot;Filevar&quot;
file=&quot;C:\Inetpub\wwwroot\_theSite\storage\112668895.jpg&quot;>

</cfhttp>

[COLOR=666666]<!--- Display the output of test.cfm --->[/color]
<cfouput>#CFHTTP.filecontent#</cfouput>

Again, don't even open test.cfm directly in your browser, it should be in a totally seperate file from this script. Run this script only, then check the directory you expect it to be in to see if the new img is there.
- tleish
 
ok, I thank you very much; with your last post I have finally understood the way the cfhttp actually works; the uploaded file was in the expected folder (with no need to open test.cfm)

what can I say, sometimes I am jus kinda slow?...

thanks B-)
Sylvano
dsylvano@hotmail.com

&quot;every and each day when I learn something new is a small victory...&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top