CFHTTP get file problem

Ask a Question related to Coldfusion - Getting Started, Design and Development.

  1. #1

    Default CFHTTP get file problem

    Hi,

    I have code to read a text file on my server and process it into a database,
    this works fine. The text file comes from a remote server that I I currently
    have to copy and paste the text file from.

    I have been trying to use cfhttp to get the file but it gets the html version
    of the file and not what is being displayed, i.e the file contains <br> at the
    end of the lines. This is causing errors when I use the 'name' variable and
    also if I try to read the file after saving http.filecontent.

    Everything works fine if I copy and paste the data from the page!

    I know there must be a way to automate this but I can not find it... any help
    is appreciated.

    Regards,
    Chris.

    cjdunkerley Guest

  2. Similar Questions and Discussions

    1. cfhttp query text file
      I use cfhttp to create a query from an ascii text file. The text file is comma delimited, with quotes around text. This works fine in CF5 and...
    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. CFHTTP Get Problem
      I have set up a Cfhttp screen to load data into my application. I am using the cfhttp tag to create a query variable that returns the data. I am...
    4. Cfhttp problem
      Im trying to loop through an array elements (in this case URLs) using cfhttp, there are several elements in the array but I can only cfhttp the...
    5. text file to query using cfhttp
      Did you ever find out what causes this issue? It's happening to me now... String index out of range: -1 Same situation, only I'm using a single...
  3. #2

    Default Re: CFHTTP get file problem

    After you read the file use Replace() to change the <br> tags to Carriage return line feeds.

    ie <cfset myText = Replace(CFHTTP.FileContent, Chr(13) & Chr(10), "ALL")>
    Stressed_Simon Guest

  4. #3

    Default Re: CFHTTP get file problem

    Thanks Simon,

    It now works! Code for reference:

    <cfhttp method="post" url="http://xxxxxxx/FILES/csv.cfm" timeout="1000">
    <cfhttpparam type="formfield" name="UserLogin" value="xxxxx">
    <cfhttpparam type="formfield" name="UserPassword" value="xxxxx">
    </cfhttp>

    <cfset p_data = Replacenocase(CFHTTP.FileContent, "<br>", Chr(13) & Chr(10),
    "ALL")>
    <cffile action="write" file="xxxxx\msepdata_test1.txt"
    nameconflict="overwrite" output="#p_data#">

    <cfx_text2query file="xxxx/msepdata_test1.txt"
    firstRowIsHeader="true" rQuery="rsPropData"> <!--- this is a custom tag
    --->

    <cfdump var="#rsPropData#">

    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