Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
cjdunkerley #1
Is looping over cfhttp possible?
Hi,
Please can some one let me know if it is possible to loop over cfhttp. I have
looked everywhere for an answer but can not get the code to work. The code I
loop over is below but it only gets the first file in the loop. I don't know
what to try next!
<cfhttp method="Get" url="http://www.theurl.com/images/#imagesArray#"
path="D:\thegpg\htdocs\images\mrm_images\">
If it not possible does anyone know another method of getting lots of images
from a remote server. FTP is not curently an option.
Thanks,
Chris.
cjdunkerley Guest
-
CFHTTP
Hello, I need to send data from a CF page to an asp.net page for processing via a URL string. The ASP page takes three parameters. Those being... -
Problem with looping over cfhttp
Hi, I am trying to get some image files from a remote server and save them to my server. I have all the paths in a query but when I loop over... -
looping through an array using cfhttp
I have a one dimensional array that is populated with string values (in this case the strings are URL's). Id like to know how i can loop through the... -
looping through array elements with cfhttp
I have a one dimensional array that is populated with string values (in this case the strings are URL's). Id like to know how i can loop through the... -
looping through arra elements with cfhttp
I have a one dimensional array that is populated with string values (in this case the strings are URL's). Id like to know how i can loop through the... -
Stressed_Simon #2
Re: Is looping over cfhttp possible?
It is possible to loop over cfhttp, I used it loads of times.
Can you please post your code again, but use the Attach Code function at the
bottom some of the code is messing up the formating but it will show properly
if you post it using Attach Code.
Stressed_Simon Guest
-
cjdunkerley #3
Re: Is looping over cfhttp possible?
Hi Simon,
Here is the code. It only gets the first image in the array? I can not make
it continue through the rest of the images, I have tried everything I can think
of and looked in the Forums for answers.
Any ideas?
Regards,
Chris.
<cfquery datasource="thegpg" name="all_mrm_data">
SELECT img_main, img_location, img_description, image1, image2, image3, image4
FROM PropertiesWOwner
WHERE DataProvider = 'MRM'
</cfquery>
<cfset qrows = 10>
<cfoutput>#qrows#</cfoutput> properties to get images for<br>
<cfset imagesArray = arraynew(1)>
<cfloop query="all_mrm_data" startrow="1" endrow="#qrows#">
<cfset ArrayAppend(imagesArray, "#img_main#")>
</cfloop>
<cfdump var="#imagesArray#">
<cfloop from="1" to="#arraylen(imagesArray)#" index="i">
<!--- See if we have this image already --->
<cfif not fileExists("D:\thegpg\htdocs\images\mrm_images\#im agesArray[1]#")>
<cfhttp method="Get"
url="http://www. the url .com/images/#imagesArray[i]#"
path="D:\thegpg\htdocs\images\mrm_images\">
</cfhttp>
<cfoutput>Got image #imagesArray[1]#</cfoutput><br>
</cfif>
</cfloop>
cjdunkerley Guest
-
Stressed_Simon #4
Re: Is looping over cfhttp possible?
Your problem is here:-
<cfif not fileExists("D:\thegpg\htdocs\images\mrm_images\#im agesArray[1]#")>
change the array reference to i not 1.
The way it is now once the first image is found and saved to the disk this
will always be false and so will not get anymore images.
HTH
Stressed_Simon Guest
-
cjdunkerley #5
Re: Is looping over cfhttp possible?
Hi Simon,
Thanks for your help, that fixed it and I understand where I was going wrong.
Thanks again.
Chris.
cjdunkerley Guest



Reply With Quote

