Update Partial with Uploaded image file

14 views
Skip to first unread message

blueHandTalking

unread,
Sep 2, 2009, 3:48:36 PM9/2/09
to Paperclip Plugin
I would like to use Paperclip to upload an image file, and then
display that image in the current page.

I have discovered that XMLHttpRequest does not handle type 'file'.
So I would like to hear how others have solved this, my first attempt
with rjs did not work.

I am using Paperclip and Hobo, both working well together.

Cheers,

Jet

Kennon Ballou

unread,
Sep 2, 2009, 5:07:15 PM9/2/09
to papercli...@googlegroups.com
I'm only aware of two ways of uploading files asynchronously: you can
either have a form in a hidden iframe that you post to and then use the
responds_to_parent plugin to allow javascript returned in the iframe to
update the page, or use a flash uploader like swfupload (check out
uploadify for a packaged version of this).

I've used both of them in different projects with relatively good success.

| Kennon Ballou
| Angry Turnip, Inc.

Jonathan Yurek

unread,
Sep 3, 2009, 2:23:59 PM9/3/09
to papercli...@googlegroups.com
Yeah, the more "standard" way of doing it is having an iframe that has
a separate form that uploads the file. This doesn't require the user
to have flash installed. I haven't personally done either method,
though.
--
Jonathan Yurek, Founder and CTO
thoughtbot, inc.
organic brains. digital solutions.

617.482.1300 x114
http://www.thoughtbot.com/

Kris Leech

unread,
Sep 3, 2009, 2:45:05 PM9/3/09
to papercli...@googlegroups.com
You will need to use a Flash based uploader.

I've been trying to get this working today based this tutorial:
http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue

I'm almost there I'm just getting slightly mangled params being sent.

Get in touch of the list ("moc.tce...@hceel.sirk".reverse) if you
want to collaborate...

Cheers Kris

blueHandTalking

unread,
Sep 4, 2009, 10:52:58 AM9/4/09
to Paperclip Plugin
Kennon,

Is there a complete example of the iframe based method you could
direct me to?
I would prefer not requiring my users be required to have Flash
installed. I ran
across some instructions for iframe method, but based on Syymfony
which I am
not familiar with, nor wish to be.

Cheers,

Jet

On Sep 3, 11:45 am, Kris Leech <kris.le...@gmail.com> wrote:
> You will need to use a Flash based uploader.
>
> I've been trying to get this working today based this tutorial:http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-...
>
> I'm almost there I'm just getting slightly mangled params being sent.
>
> Get in touch of the list ("moc.tcenokre...@hceel.sirk".reverse)  if you
> want to collaborate...

Kennon Ballou

unread,
Sep 4, 2009, 11:22:51 AM9/4/09
to papercli...@googlegroups.com
Check out the README for the responds_to_parent plugin on github:
http://github.com/markcatley/responds_to_parent/tree/master

That's a very basic example, but should give you an idea of how to do
it. Basically you just have an invisible iframe on the page, and you set
the target= attribute of the form to post to the iframe. You then render
rjs in the controller to update the page in the response that gets
loaded in the iframe.

You need the responds_to_parent plugin installed because by default the
javascript being rendered inside of an iframe can't talk to the parent
page/document.

If you set up some js event handlers to turn on a spinning wheel when
you hit submit for the form, etc, you can have a nice ajaxy upload form
without reloading the page.

| Kennon Ballou
| Angry Turnip, Inc.

blueHandTalking wrote:
Reply all
Reply to author
Forward
0 new messages