Saturday, January 24, 2009

Inline file upload - iframe - ajax - Ruby on Rails

In View

<% form_for(@images, :url => formatted_images_path(:format => 'js'), :html => { :multipart => true,:target => 'upload_frame' }) do |f| %>
Image
<%= f.file_field :uploaded_data, :size => "50" %>
<%= f.submit :Submit %>
<% end %>
< id="'upload_frame'," name="upload_frame" style="width:1px;height:1px;border:0px" src = "about:blank">

in controller
def create
@image = Image.new
if @image.save
respond_to do |format|
format.js do
responds_to_parent do
render :update do |page|
page.replace_html 'imgupload', :partial => 'imageupload',:object => @images
page.visual_effect :highlight, "image_#{@image.id}"
end
end
end
end
end
end

2 comments:

Contact Me for any help regarding rails/nodejs/php/mysql

Name

Email *

Message *