 |
| 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
|
|
|
|

August 19th, 2004, 01:44 AM
|
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

August 19th, 2004, 01:57 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Please specify the format of the text file. If it contains a text block that is getting repeated for each product, this is possible.
|
|

August 19th, 2004, 02:20 AM
|
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

August 19th, 2004, 02:26 AM
|
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

August 19th, 2004, 02:56 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

August 19th, 2004, 03:43 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|
|

August 19th, 2004, 05:34 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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 ?
|
|

August 19th, 2004, 05:41 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|
|

August 19th, 2004, 05:51 AM
|
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

August 19th, 2004, 05:56 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Can you post your code - very difficult to event guess with just an error message.
Cheers,
Chris
|
|
 |