ColdFusion ... doing a CFHTTP call inside a CFLOOP
Okay so this is lame but I have a file/ftp server that serves the assets for my web application. The client set up the ftp server before I started the application.
So it works fine when I just show images in my app. Even though it is cross domain. Now the client wants me to be able to take all of the assets for each test and bundle it up in a zip file. Oh and they won't upgrade so we are using CF7!!
So okay I make a list of the images and then I loop over it and do the cfhttp call inside the loop. Write the image to a temp directory I set up and then zip the whole damn thing up. It works except for the cfhttp call. I get the first image and then nothing.
<cfset imageList = "image_01.png,image_02.png" />
<cfloop index="strImage" list="#imageList#" delimiters=",">
<cfhttp method="GET" url="#theImgPath##strImage#" path="#TempPath##OSdelim#images" result="objGet" />
</cfloop>
The first image shows up on the server the second one does not.
Any idea if I am doing anything wrong?
I'd try something like:
<!--- Lose the forward slash at the end, CF isn't XHTML --->
<cfset imageList = "image_01.png,image_02.png">
<cfloop index="strImage" list="#imageList#" delimiters=",">
<cfset fileName = strImage>
<cfif not fileExists(TempPath & OSdelim & "images" & OSdelim & strImage)>
<cfhttp method="get" getAsBinary="yes" url="#theImgPath##strImage#" path="#TempPath##OSdelim#images" file="#localfile#">
downloading... <br />
<cfelse>
<cfoutput>#TempPath# #OSdelim# images #strImage# already exists</cfoutput><br />
</cfif>
</cfloop>
The code is untested, but I reckon it should work, or at least give you a good grasp of where you're going wrong with the paths (in case you are)
链接地址: http://www.djcxy.com/p/31198.html上一篇: coldfusion和超过时间限制