Forum: Ruby on Rails Prototype Ajax + File Uploading-- How?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Matthew F. (Guest)
on 2006-02-19 09:01
(Received via mailing list)
Good evening!

I'm currently trying to submit some data and a file upload through Ajax.
  I'm using rails & prototype, and somewhere there's a disconnect.  I'm
reasonably convinced the file upload isnt being sent at all, or if it
Rails has absolutely no idea.  The form itself heads with:

<form onsubmit="new Ajax.Request('create', {onSuccess: postNew,
Form.serialize(this)} ); return false;">
<input type="file" name="if" id="image_file">

The logs show everything else getting submitted normally, but I'm not
params[:if] or params[:image_file] (not sure which I should expect, but
neither are there), nor am I seeing anything in the logs from the
fastcgi install;

Processing AdminInterfaceController#create (for W.X.Y.Z at 2006-02-19
01:31:25) [POST]
  Parameters: {"dp"=>{"picture_file"=>"", "city"=>"PORTSMOUTH",
"latitude"=>"43.078843", "title"=>"Market JUNK", "geo_source"=>"Yahoo",
"zipcode"=>"03801-3730", "description"=>"", "street"=>"128 MARKET ST",
"longitude"=>"-70.758461", "user_location"=>"128 market st",
"commit"=>"Capture", "action"=>"create",

Pardon the verbosity; again, nothing from the file input form object.

Even if I give the file input a id="dp_picture_file"
name="dp[picture_file]", dp[:picture_file] is still "", still nothing.

I'm pretty sure Prototype is just not serializing the file-input at all.
How can I get the file to upload and, if necessary, serialize, and how
can I
make this cleanly integrate with rails?

Many thanks!
Roberto S. (Guest)
on 2006-02-19 09:07
(Received via mailing list)
take a look here:
Matthew F. (Guest)
on 2006-02-19 09:19
(Received via mailing list)
Whoo, not pretty.  Should work though, thanks!  Thank heaven someone far
smarter than I ran this problem down recently.

With rails, Ajax &co is easy as pie, heaven forbid I have to actually,
know, start worrying about hidden iFrames & such.

This topic is locked and can not be replied to.