Yes, cflooping around a cfhttp does cause problems. I believe this is a 
known problem, and may still be a problem in CFMX 6.1. The best way 
around it is to put your cfhttp call in a cffunction, then call that 
function from within your loop. It makes no sense why that works better, 
but it will fix it.

-nathan strutz
http://www.dopefly.com/


Andrew Spear wrote:
> That's what I'm doing.  I've even taken the image path that is cfoutputed and 
> hardcoded it in the CFHTTP to make sure the path was ok - and it downloads 
> fine.  I might as well post the code.  You'll just have to change the URL 
> param in the first CFHTTP call and the SaveToDir var.
> 
> <cfhttp url="http://"; method="GET" resolveurl="Yes" />
> <cfset SaveToDir = "D:\internet\wwwroot\cf\images\">
> <cfset Page = cfhttp.filecontent>
> <cfset NewPage = Page>
> <CFSET CRLF = Chr(13) & Chr(10)> 
> 
> <CFLOOP LIST="#Page#" DELIMITERS="#CRLF#" INDEX="TheLine">
>       <cfset Search = 1>
>       <cfset LinNum = 1>      
> 
>       <cfloop condition="Search EQ 1">
>               <cfset ImgPos = 
> REFindNoCase("<img[^>]+>",TheLine,LinNum,"true")>
>               <cfif ImgPos.Pos[1] GT 0>
>                       <cfscript>
>                       ImgTag          = 
> Mid(TheLine,ImgPos.Pos[1],ImgPos.Len[1]);
>                       ImgSource       = REFindNoCase("src[ ]?=[ 
> ]?([\'""]([^\'""]+)[\'""]|([^\s]))",ImgTag,1,"true");
>                       ImgSource       = 
> Mid(ImgTag,ImgSource.Pos[3],ImgSource.Len[3]);
>                       ImgSource       = 
> ReplaceNoCase(ImgSource,'../','','all');              
>                       </cfscript>
>                       <cftry>
>                               <cfoutput>#ImgSource#</cfoutput><br>
>                               <cfhttp url="#ImgSource#" method="GET" 
> path="#SaveToDir#" throwonerror="yes">
>                               <cfset NewPage = 
> ReplaceNoCase(NewPage,ImgSource,"http://localhost/cf/images/#ListLast(ImgSource,"/")#","all")>
>                               <cfcatch>Error</cfcatch>
>                       </cftry>
>                       <cfset LinNum = ImgPos.Pos[1] + ImgPos.Len[1]>
>               <cfelse>
>                       <cfset Search = 0>
>               </cfif>
>       </cfloop>
> 
> </CFLOOP>
> 
> <cffile action="WRITE" file="#SaveToDir#\index.html" output="#NewPage#" 
> addnewline="Yes">
> 
> 
> 
>>Are you sure they're running?  What if you put a CFOUTPUT before each
>>CFHTTP that lists the image that it's about to download?
>>
>>cheers,
>>barneyb
>>
>>On Fri, 03 Dec 2004 16:34:26 -0400, Andrew Spear
>><[EMAIL PROTECTED]> wrote:
>>-- 
>>Barney Boisvert
>>[EMAIL PROTECTED]
>>360.319.6145
>>http://www.barneyb.com/blog/
> 
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Silver Sponsor - RUWebby
http://www.ruwebby.com

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:186298
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to