Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grabbing Images.. 1

Status
Not open for further replies.

brantGuy

Programmer
Feb 12, 2007
59
CA
I just purchased a news rss.20 feed...

Im grabbing the feed, and parsing it to my database and displaying it on my site from the DB...I wrote a cron that updates once every 30 minutes to check if rss has changed.

alot of these feeds come with video, images and soundclips.
I tried to grab the image but to no avail..I have the image name and location, how can grab it using CF

Craig
 
there is an answer, but you're not going to like it based on your experieces with cfhttp in your other post, but the solution is to do a cfhttp to the image location, and then a base64 of the content that comes back to turn it into an image, this should then be readable by the browser

hope this helps!

Tony
 
Hi Tony

Its not that I got a problem with cfhttp...lol..
its the speed...I want this to run in the background so I can serve it to my site visitors faster...how long it takes for me to get it is irrvellavent...its how fast the serfer gets it is the point..

if you could please elaborate on the base64 idea, it would be greatly appriciated...

Craig
 
been researching base64, I still cant figure it out for my senario...I think this approach will actually store the image in the db and not a directory.

I just want the image name in the directory and the actual image stored in a folder.


Craig
 
Sorry, for the delay in getting back to you and I was leading you up the wrong garden path, with the base64 thing, it was for something else i had to do with images and cfhttp.

All you should need is this:
Code:
<cfhttp url="your_url_with_image"
        method="get"
        path="c:\some_directory"
        file="name.jpg" />

that should do it.

Hope this helps!

Tony
 
hey Tony

I modified it a bit..but there seems to be a problem
Code:
<cfquery datasource="#DSN#" name="qPullLinks">
SELECT * from 
ahnFeed
where imageLink <> '' 
</cfquery>
<cfoutput>#qPullLinks.recordCount#</cfoutput> 
<cfoutput query="qPullLinks">
Getting Image: <img src="#qPullLinks.imageLink#" /><br />
<cfhttp url="#qPullLinks.imageLink#"
        method="get"
        path="d:\branford.com\beta5\images\feeds\temp"
        file="#RIGHT(qPullLinks.imageLink, 9)#" />
		
</cfoutput>

it pulls the images and displays them on my page but wont put them in the directory specified
 
i know that tis is going to sound stupid, but can you put the cfhttp into a cfinclude, no change to the code but into a cfinclude. i had a problem with something like that a while ago and that sorted it. mind you i thought that the issue had been fixed in cf!

Hope this helps!

Tony
 
I've noticed a few situations in CF where you have to use an include to get the code to run properly...

my server is down right now and im unable to test grrrrr.

hmmmmm I think you may have solved another one of my problems with that post...2 for the price on one...

The other problem is I have a scheduled task to be run by the cfadministrator but it refuses to run cause the file it sees as a redirect...basically, I use that file to read the xml feed every 30 mins and update the DB if Necessary..

maybe I will put the cfhttp there in an include as well...



I will advise on outcome..

Craig
 
I got it partially working..

only problem is now is I put in a variable for the name and it dont work, will only accept hardcoded name.
 
so figured out that I didnt need to use the name attribue with a get cause it defaults to the name of the file your getting, which works for me but I can see issuews with that.

now, i noticed it not looping the query
 
Can you post where you are getting the rss from and i'll try and knock it up and see if i can get it to work
 
I would like to but I cant...

Its a purchased feed and my boss would flip if he found out...

 
Can you post the url's for some of the images, and I'll create a query to mimic yours
 
weird! this works fine for me:
Code:
 <cfset qPullLinks = QueryNew("imageLink")> 
 <cfset temp = QueryAddRow(qPullLinks, 3)> 
 <cfset temp = QuerySetCell(qPullLinks, "ImageLink", "[URL unfurl="true"]http://media.allheadlinenews.com/media/8/78018.jpg",[/URL] 1)> 
 <cfset temp = QuerySetCell(qPullLinks, "ImageLink", "[URL unfurl="true"]http://media.allheadlinenews.com/media/6/77996.jpg",[/URL] 2)> 
 <cfset temp = QuerySetCell(qPullLinks, "ImageLink", "[URL unfurl="true"]http://media.allheadlinenews.com/media/e/77162.jpg",[/URL] 3)> 

 <cfloop query="qPullLinks"> 
  <cfinclude template="something.cfm"> 
 </cfloop>

then something.cfm is:
Code:
<cfhttp url="#qPullLinks.imageLink#" 
method="get" 
path="c:\" />

what version of cf are you using? I've got the latest

Does the above code work for you?

Hope this helps!

Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top