PDA

View Full Version : cfhttp to save image file locally. Help with code


contiw
05-15-2005, 05:23 PM
This call to a webcam
<cfhttp url="http://www.comune.pesaro.ps.it/CamImageGet.asp">

and a littlebit of string manipulation:

<cfset blabla = cfhttp.fileContent>
<cfset firstpos = findnocase("/webcam/",blabla)>
<cfset img = mid(cfhttp.fileContent,firstPos,28)>

I get the path and the name of the picture:
/webcam/123456789_webcam.jpg

which I put successfully on he screen:
<img src='http://www.comune.pesaro.ps.it<cfoutput>#img#</cfoutput>'>

Now i need to give the user the capability to save it somewhere
locally :

<cfhttp
method="Get"
url="http://www.comune.pesaro.it#img#"
path="c:\webcam\"
file="My_SavedBinary.jpg"></cfhttp>

but this code does not work.
The "url' parameter seems well formed with the #img# variable.
The subdirectory exists.

<cfoutput>#cfhttp.MimeType#</cfoutput>
returns : Unable to determine MIME type of file.

<cfoutput>cfhttp.errorDetail = #cfhttp.errorDetail#<br></cfoutput>
returns : Unknown host: www.comune.pesaro.it: www.comune.pesaro.it

What's missing?

--------------------------------

Simplified code here :

<cfhttp url="http://www.comune.pesaro.ps.it/CamImageGet.asp">
<cfset blabla = cfhttp.fileContent>
<cfset firstpos = findnocase("/webcam/",blabla)>
<cfset img = mid(cfhttp.fileContent,firstPos,28)>

<cfoutput><br>var img = #img#<br></cfoutput>

<img src='http://www.comune.pesaro.ps.it<cfoutput>#img#</cfoutput>'>

<cfhttp
method="Get"
url="http://www.comune.pesaro.it#img#"
path="c:\webcam\"
file="My_SavedBinary.jpg"></cfhttp>

<cfoutput>#cfhttp.MimeType#</cfoutput>

ThankYou
wConti