943,771 Members | Top Members by Rank

Ad:
  • ASP Discussion Thread
  • Unsolved
  • Views: 16288
  • ASP RSS
Oct 28th, 2008
0

how to download image physical files from other server through URL

Expand Post »
hello..i got some question about downloding and save the image from other server to my server and also change the file name.
i have no idea on it. i hope can get some help from here.

let say i have a url that pass back from the Picnik API like this:

http://www.picnik.com/file/abc.jpg

i would like to get this image physical files and save it into my server, and replace it to my original image.

how can i do it? using aspjepg? or aspsmart upload?

thanx..hope to hear from u all soon...
thank you very very much
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
yenyen is offline Offline
24 posts
since Aug 2006
Nov 3rd, 2008
0

Re: how to download image physical files from other server through URL

right click on the image... save as... then upload it to your server or photobucket or imageshack.....

In photobucket you can put the URL in and then it uploads that photo to your account.

Done
Last edited by cohen; Nov 3rd, 2008 at 9:08 pm.
Featured Poster
Reputation Points: 46
Solved Threads: 45
Practically a Posting Shark
cohen is offline Offline
819 posts
since Nov 2008
Nov 7th, 2008
-1

Re: how to download image physical files from other server through URL

Aren't you forgetting something cohen? What about copyrights?
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 871
Code tags enforcer
peter_budo is offline Offline
6,656 posts
since Dec 2004
Nov 9th, 2008
0

Re: how to download image physical files from other server through URL

Click to Expand / Collapse  Quote originally posted by peter_budo ...
Aren't you forgetting something cohen? What about copyrights?
oh.... and there's that..... didn't think about that....

for yenyen - you would need to check that with the domain webmaster.
Featured Poster
Reputation Points: 46
Solved Threads: 45
Practically a Posting Shark
cohen is offline Offline
819 posts
since Nov 2008
Nov 13th, 2008
0

Re: how to download image physical files from other server through URL

Hi,
aside the mentioned restrictions, saving images on your server would be quite difficult. Usually the images are sent to the browser, that means you have to use a virtual browser in order to get the image onto your server. A browser receives all images, in this case your server would receive many images from the other server.
Reputation Points: 11
Solved Threads: 7
Junior Poster in Training
Baradaran is offline Offline
88 posts
since Feb 2007
Nov 19th, 2008
0

Re: how to download image physical files from other server through URL

You guys sure give up easy

I wrote this little script for you guys, examples included.

asp Syntax (Toggle Plain Text)
  1. <%
  2. 'Fetch and save this image
  3. Call fetchDocument("http://www.iportalx.net/images/iportalx-welcome.gif", Server.MapPath("./"))
  4.  
  5. 'Fetech and save this document
  6. Call fetchDocument("http://www.daniweb.com/forums/thread153966.html", Server.MapPath("./"))
  7.  
  8.  
  9. 'Created by Drew Gauderman
  10. 'Website: [url]http://www.iportalx.net[/url]
  11. Function fetchDocument(strDocURL, strSavePath)
  12. 'Create the XMLHTTP object to fetch the image
  13. Set objXmlHTTP = Server.CreateObject("Microsoft.XMLHTTP")
  14.  
  15. 'Get the image
  16. objXmlHTTP.Open "GET", strDocURL, False
  17. objXmlHTTP.Send
  18.  
  19. 'Create Stream object
  20. Dim objStream
  21. Set objStream = Server.CreateObject("ADODB.Stream")
  22.  
  23. With objStream
  24. 'Specify stream type - we want To save binary data.
  25. .Type = 1
  26.  
  27. 'Open the stream And write binary data To the object
  28. .Open
  29. .Write objXmlHTTP.ResponseBody
  30.  
  31. 'Save binary data To disk
  32. .SaveToFile strSavePath & "/" & Mid(strDocURL, InstrRev(strDocURL, "/")), 2
  33.  
  34. 'Clean up objects
  35. .Close
  36. End WIth
  37.  
  38. Set objXmlHTTP = Nothing
  39. Set objStream = Nothing
  40. End Function
  41. %>
Last edited by Drew; Nov 19th, 2008 at 5:09 pm. Reason: added asp code highlighting
Reputation Points: 25
Solved Threads: 7
Junior Poster
Drew is offline Offline
166 posts
since Apr 2004
Nov 28th, 2008
0

Re: how to download image physical files from other server through URL

Drew,

You rock! This is just what I was looking for... I was searching for a way to save webpage thumbnails created from websnapr.com for my website: <URL SNIPPED>

I could have used websnapr to dynamically create the thumbnails each time the page was loaded, but figured if I could save them it would be better/easier to controll.... also, by saving the images I can include them in my RSS feed (websnapr images dont work with RSS).

Anyhow, thanks Drew for your awesome and simple example... here's teh code I used:

<%
'Fetch and save this image
'Call fetchDocument("http://www.iportalx.net/images/iportalx-welcome.gif", Server.MapPath("./"), "myimagename.jpg")

'Fetech and save this document
'Call fetchDocument("http://www.daniweb.com/forums/thread153966.html", Server.MapPath("./"), "mydocumentname.doc"))


'Created by Drew Gauderman
'Website: http://www.iportalx.net
Function fetchDocument(strDocURL, strSavePath, newImageName)
	'Create the XMLHTTP object to fetch the image
	Set objXmlHTTP = Server.CreateObject("Microsoft.XMLHTTP")

	'Get the image
	objXmlHTTP.Open "GET", strDocURL, False
	objXmlHTTP.Send

	'Create Stream object
	Dim objStream
	Set objStream = Server.CreateObject("ADODB.Stream")

	With objStream
		'Specify stream type - we want To save binary data.
		.Type = 1

		'Open the stream And write binary data To the object
		.Open
		.Write objXmlHTTP.ResponseBody

		'Save binary data To disk
		.SaveToFile strSavePath & "\" & newImageName

		'Clean up objects
		.Close
	End WIth

	Set objXmlHTTP = Nothing
	Set objStream = Nothing
End Function
%>

This way I can save the image to the path I want and also save the filename using a key-identifier with the record I'm saving... making it easy to dynamically create and delete.

Thanks again.

~Mikel
Last edited by peter_budo; Nov 29th, 2008 at 5:31 am. Reason: Keep It Spam-Free - Do not spam, advertise, plug your website, or engage in any other type of self promotion.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mdeeter is offline Offline
1 posts
since Nov 2008
Nov 29th, 2008
0

Re: how to download image physical files from other server through URL

Glad you like it
Reputation Points: 25
Solved Threads: 7
Junior Poster
Drew is offline Offline
166 posts
since Apr 2004
Dec 7th, 2008
0

Re: how to download image physical files from other server through URL

this is a solution how to save image from url to your server:
1. get Stream from URL using WebRequest class
2. Create Image object from stream using System.Drawing.Image.FromStream method
3. Save file on disk using System.Drawing.Image.Save method

details:
http://mxdev.blogspot.com/2008/12/ge...et-aspnet.html

or you mean "server" is not the server from which code is executed?


Click to Expand / Collapse  Quote originally posted by yenyen ...
hello..i got some question about downloding and save the image from other server to my server and also change the file name.
i have no idea on it. i hope can get some help from here.

let say i have a url that pass back from the Picnik API like this:

http://www.picnik.com/file/abc.jpg

i would like to get this image physical files and save it into my server, and replace it to my original image.

how can i do it? using aspjepg? or aspsmart upload?

thanx..hope to hear from u all soon...
thank you very very much
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mxdevit is offline Offline
2 posts
since Sep 2008
Dec 7th, 2008
0

Re: how to download image physical files from other server through URL

That is ASP.Net, and that is completely different from ASP. Might want to pay attention next time.
Reputation Points: 25
Solved Threads: 7
Junior Poster
Drew is offline Offline
166 posts
since Apr 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP Forum Timeline: data transfer with encrypted format
Next Thread in ASP Forum Timeline: How to display online users Details( username ) and count Using ASP





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC