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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community 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
is,
Rails has absolutely no idea.  The form itself heads with:

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

The logs show everything else getting submitted normally, but I'm not
seeing
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
running
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",
"state"=>"NH"},
"commit"=>"Capture", "action"=>"create",
"controller"=>"admin_interface"}

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!
rektide
Roberto S. (Guest)
on 2006-02-19 09:07
(Received via mailing list)
take a look here:

http://www.kylemaxwell.com/
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,
you
know, start worrying about hidden iFrames & such.

Thanks,
Myren
This topic is locked and can not be replied to.