# Any way to submit an image as part of a form (Javascript?)

**URL:** <https://www.ruby-forum.com/t/any-way-to-submit-an-image-as-part-of-a-form-javascript/167027>\
**Category:** Rails\
**Created:** [May 2, 2009, 1:15pm UTC](https://www.ruby-forum.com/t/any-way-to-submit-an-image-as-part-of-a-form-javascript/167027 "2009-05-02T13:15:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![itsastickup](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/7feea3/32.png) [@itsastickup](https://www.ruby-forum.com/u/itsastickup)\
**Post date:** [May 2, 2009, 1:15pm UTC](https://www.ruby-forum.com/t/any-way-to-submit-an-image-as-part-of-a-form-javascript/167027/1 "2009-05-02T13:15:30Z")

</div>

I would like to submit the data of a rendered image from the users  
browser in a form. Is this possible? (My reasons are not illegal, by  
the way). I’m going to be storing it in a database for viewing at  
another time.

I know this question begs the question why not do it some other way  
etc etc, and may get me some “What are you trying to achieve?”, but I  
would appreciate a straight answer.

---

<div class="post-metadata">

**Author:** ![itsastickup](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/7feea3/32.png) [@itsastickup](https://www.ruby-forum.com/u/itsastickup)\
**Post date:** [May 2, 2009, 2:27pm UTC](https://www.ruby-forum.com/t/any-way-to-submit-an-image-as-part-of-a-form-javascript/167027/2 "2009-05-02T14:27:10Z")

</div>

itsastickup wrote:

> I would like to submit the data of a rendered image from the users  
> browser in a form. Is this possible? (My reasons are not illegal, by  
> the way). I’m going to be storing it in a database for viewing at  
> another time.

Ahh, I see. “Judge, I did not violate that person’s copyright–all I  
did was copy it for viewing at a later date.” lol.

---

<div class="post-metadata">

**Author:** ![itsastickup](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/7feea3/32.png) [@itsastickup](https://www.ruby-forum.com/u/itsastickup)\
**Post date:** [May 2, 2009, 2:46pm UTC](https://www.ruby-forum.com/t/any-way-to-submit-an-image-as-part-of-a-form-javascript/167027/3 "2009-05-02T14:46:15Z")

</div>

> Ahh, I see. “Judge, I did not violate that person’s copyright–all I  
> did was copy it for viewing at a later date.” lol.

The site from which this will happen has explicit permission for  
copying of images.

If you had taken my word for it instead of presuming I would not be  
posting this message.

Presumption is the sign of a person who has not reached maturity but  
presumption in the face of a person’s word is absurd.

---

<div class="post-metadata">

**Author:** ![itsastickup](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/7feea3/32.png) [@itsastickup](https://www.ruby-forum.com/u/itsastickup)\
**Post date:** [May 2, 2009, 4:56pm UTC](https://www.ruby-forum.com/t/any-way-to-submit-an-image-as-part-of-a-form-javascript/167027/4 "2009-05-02T16:56:47Z")

</div>

On May 2, 4:14 am, itsastickup [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I would like to submit the data of a rendered image from the users  
> browser in a form.

do you mean you’d like to allow users to upload images?

-eric

---

<div class="post-metadata">

**Author:** ![itsastickup](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/7feea3/32.png) [@itsastickup](https://www.ruby-forum.com/u/itsastickup)\
**Post date:** [May 2, 2009, 4:10pm UTC](https://www.ruby-forum.com/t/any-way-to-submit-an-image-as-part-of-a-form-javascript/167027/5 "2009-05-02T16:10:40Z")

</div>

unknown wrote:

> > Ahh, I see. ï¿½"Judge, I did not violate that person’s copyright–all I  
> > did was copy it for viewing at a later date." ï¿½ lol.
> 
> The site from which this will happen has explicit permission for  
> copying of images.
> 
> If you had taken my word for it instead of presuming I would not be  
> posting this message.
> 
> Presumption is the sign of a person who has not reached maturity but  
> presumption in the face of a person’s word is absurd.

lol.

A web page is not allowed to sniff around on a user’s computer and look  
for material to blackmail them with, e.g. a priest with 100,000 images  
of naked children in his browser’s cache.

---

<div class="post-metadata">

**Author:** ![itsastickup](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/7feea3/32.png) [@itsastickup](https://www.ruby-forum.com/u/itsastickup)\
**Post date:** [May 2, 2009, 10:54pm UTC](https://www.ruby-forum.com/t/any-way-to-submit-an-image-as-part-of-a-form-javascript/167027/6 "2009-05-02T22:54:19Z")

</div>

“I would like to submit the data of a rendered image”

What do you mean by “rendered”? Was the image generated via Flash or  
something similar? If so, then the flash applet can just submit a POST  
request (multipart/form-data) with the image as a string. Otherwise,  
you’ll need to clarify exactly what you’re trying to do, as it sounds  
like you’re just trying to upload an image (which due to browser  
security, _cannot_ be done with javascript).

---

<div class="post-metadata">

**Author:** ![itsastickup](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/7feea3/32.png) [@itsastickup](https://www.ruby-forum.com/u/itsastickup)\
**Post date:** [May 3, 2009, 6:56pm UTC](https://www.ruby-forum.com/t/any-way-to-submit-an-image-as-part-of-a-form-javascript/167027/7 "2009-05-03T18:56:19Z")

</div>

Hi Eric and pharington,

I’m not certain what you mean by “upload an image” and I don’t mean an  
upload from the user’s own harddisk as with an edit box for the path  
etc.

So to clarify: rather I supply the user with a form that has an ‘img’  
tag to an image on another site and which the user can see (rendered).  
If the user submits the form I get the server to itself fetch the  
image from the other server but I am exploring the possibility of  
directly uploading what is in the client’s browser to my rails server  
avoiding that second fetch from the other server. It won’t save my  
rails server bandwidth but it will save the other server.

I suspect you’ve already answered my question with the ‘javascript  
security’ mention, but I’m not sure.

Am I’m stumbling over the cross-site restrictions, irrespective of  
javascript, and that there is no way of doing this?

---

<div class="post-metadata">

**Author:** ![itsastickup](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/7feea3/32.png) [@itsastickup](https://www.ruby-forum.com/u/itsastickup)\
**Post date:** [May 5, 2009, 12:30am UTC](https://www.ruby-forum.com/t/any-way-to-submit-an-image-as-part-of-a-form-javascript/167027/8 "2009-05-05T00:30:08Z")

</div>

I’ve been thinking about my previous post and have concluded I owe you  
an apology for exactly the crime I accused you of: presumption. You’ll  
see I presumed upon your motive for posting, which may have just been  
humour rather than a snide remark. Looks like I;m the immature juve  
after all.

So sorry for that.
