# How to save an image from URL

**URL:** <https://www.ruby-forum.com/t/how-to-save-an-image-from-url/122139>\
**Category:** Rails\
**Created:** [December 4, 2007, 9:43pm UTC](https://www.ruby-forum.com/t/how-to-save-an-image-from-url/122139 "2007-12-04T21:43:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [December 4, 2007, 9:43pm UTC](https://www.ruby-forum.com/t/how-to-save-an-image-from-url/122139/1 "2007-12-04T21:43:05Z")

</div>

In my application users can upload images from the local machine. But I  
also want to provide them to upload their images by telling the app the  
full url to the an image on the web. How do I save the image on the  
local machine from the url.

Thanks

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [December 4, 2007, 11:57pm UTC](https://www.ruby-forum.com/t/how-to-save-an-image-from-url/122139/2 "2007-12-04T23:57:28Z")

</div>

On Dec 4, 2007 2:43 PM, Raj S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> In my application users can upload images from the local machine. But I  
> also want to provide them to upload their images by telling the app the  
> full url to the an image on the web. How do I save the image on the  
> local machine from the url.

require ‘net/http’

Net::HTTP.start( ‘[static.destiney.com](http://static.destiney.com)’ ) { |http|  
resp = http.get( ‘/ror\_vs\_c\_asm.jpg’ )  
open( ‘/tmp/ror\_vs\_c\_asm.jpg’, ‘wb’ ) { |file|  
file.write(resp.body)  
}  
}

–  
Greg D.  
[http://destiney.com/](http://destiney.com/)

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [April 20, 2009, 11:40am UTC](https://www.ruby-forum.com/t/how-to-save-an-image-from-url/122139/3 "2009-04-20T11:40:38Z")

</div>

Raj S. wrote:

> In my application users can upload images from the local machine. But I  
> also want to provide them to upload their images by telling the app the  
> full url to the an image on the web. How do I save the image on the  
> local machine from the url.
> 
> Thanks

Hi Raj,

It delayed reply but Useful one.

Now it was available as a desktop application.

goto → [Box](http://www.box.net/shared/m5vxqpr3r1)

Regards,  
P.Raveendran

> **[Raveendran](https://raveendran.wordpress.com/)**
>
> Nothing is impossible...
