Spidering and Saving Images with CFHTTP and CFFILE

Posted by: scoopseven 15 years, 1 month ago

Goal: To spider a site (our own site) and save all image files from the pages on that site to a hard disk on another server. Thanks to Ben Nadel for showing me the way on this one.  For some reason the path/file attributes on cfhttp were not allowing me to save a image file to the hard disk on our linux (CentOS) server. I thought I could save the file using cfcontent somehow, which led me to Ben's post. Never thought to just save the binary stream using cffile. Not sure if there was a permissions problem or what, but here's the work-around.
<!--- Grab the image file. ---> <cfhttp method="get" url="http://www.myurl.com/someimage.jpg" useragent="#CGI.http_user_agent#" getasbinary="yes" result="objGet"  /> <!--- Save the image file. ---> <cffile action="write"  output="#objGet.FileContent#"  mode="777"  file="/mypath/myimage.jpg">
This worked like a charm.  Again, not sure if this was cfhttp doesn't support the "mode" attribute or what, but it helped immensely.  Thanks, Ben.

Currently unrated


Recent Tweets

Recent Posts

Archive

2013
2012
2011
2010
2009
2008
2007
2006

Categories

Authors

Feeds

RSS / Atom