Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 19th, 2004, 01:44 AM
Authorized User
 
Join Date: Aug 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Retrieve and store the images from server URL

Hi,

I receive datafeeds as a .txt format that hold their product inventories including fields for all the product
details like price, description, categories, etc.
Two of those fields are for product image locations for a thumbnail and a larger image file. For instance:

Thumbnail: http://www.x.com/images/thumbnails/imgx.jpg
Full Image: http://www.x.com/images/images/imgx.jpg

Is there a way to write an ASP script that will loop through all the records in the datafeed and
retrieve and store the images? I have no idea how I could do this.

~Thanks
 
Old August 19th, 2004, 01:57 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

Please specify the format of the text file. If it contains a text block that is getting repeated for each product, this is possible.
 
Old August 19th, 2004, 02:20 AM
Authorized User
 
Join Date: Aug 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by madhukp
 Please specify the format of the text file. If it contains a text block that is getting repeated for each product, this is possible.
Thanks for reply,
Datafeed file(.text) format like...

Top row contains colum name
each values separated with tab

My main problem is "How to retrieve images from 'http://www.x.com/images/thumbnails/imgx.jpg' please help me.
 
Old August 19th, 2004, 02:26 AM
Authorized User
 
Join Date: Aug 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually i want to use same images that mention on datafeed...
So i have to store it on my server ...

Is there any programming way?

~Thanks
 
Old August 19th, 2004, 02:56 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

AFAIK, there is no way other than fetching image file through an FTP component. There are many FTP components like (dart, chillkat etc.). You can use one of them to fetch the images from remote server. But this is not an advisable way. You need username and password to connect to remote server. The path etc. of remote server may change over time in which case you have to make changes to your code.

You can put the http path as the source of image. Like
<img src="http://www.x.com/images/thumbnails/imgx.jpg">

I think the http path is also got from the feed. Then you do not have to change the code when the image path changes at the remote server.
 
Old August 19th, 2004, 03:43 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hey ccc_storage,

This should do it...

Code:
Dim xmlHttp
Set xmlHttp = Server.CreateObject("MSXML2.XmlHttp.4.0")
Call xmlHttp.open("GET", "[target file]")
Call xmlHttp.send()

Dim stream
Set stream = Server.CreateObject("ADODB.Stream")
stream.Type = adTypeBinary
Call stream.Open()
Call stream.Write(xmlHttp.responseBody)
Call stream.SaveToFile("[save as file]", adSaveCreateOverWrite)
Call stream.Close()
Set stream = Nothing

Set xmlHttp = Nothing
HTH,

Chris

 
Old August 19th, 2004, 05:34 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

Hello Chris,

Thanks a lot for showing me another way.

But the following line gives an error.

stream.Type = adTypeBinary

The error is:

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

May I know what is the problem ?
 
Old August 19th, 2004, 05:41 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi,

You need to reference the ado constants (or substitute in the appropriate values), this was recently discussed in the following thread...

http://p2p.wrox.com/topic.asp?TOPIC_ID=17068

Best regards,

Chris

 
Old August 19th, 2004, 05:51 AM
Authorized User
 
Join Date: Aug 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks
your reply help me lots...

still my hope live...
After using your code i able to create file on server

But Currently it gives this error
"Operation is not allowed in this context. "

where i am going wrong..
~thanks
 
Old August 19th, 2004, 05:56 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Can you post your code - very difficult to event guess with just an error message.

Cheers,

Chris






Similar Threads
Thread Thread Starter Forum Replies Last Post
Store and Retrieve Images in SQL Database derekl ASP.NET 1.0 and 1.1 Professional 4 December 19th, 2007 03:16 AM
asp, store, retrieve form value from cookies? kumiko Classic ASP Basics 0 November 24th, 2007 12:33 PM
How to store and retrieve formatted strings in db jessi Classic ASP Professional 2 March 9th, 2007 07:27 AM
How to store image in oracle database and retrieve y.suresh JSP Basics 1 February 28th, 2005 07:01 AM
How do you store and retrieve a hierachy Hubman Pro VB.NET 2002/2003 0 August 4th, 2003 09:37 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.