Is looping over cfhttp possible?

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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...
    4. 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...
    5. 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...
  3. #2

    Default 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

  4. #3

    Default 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

  5. #4

    Default 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

  6. #5

    Default 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139