thank u for your kind rply..
i ve uploaded file/image into database and folder named "data".. and i
also able to update the uploaded files/images in database ..but dont
know how to ..in folder "data"..
heres my controller file
def create
@show =Show.new(params[:show])
@show.filename=
params[:show][''filename''].original_filename
if @show.save
post = Show.save(params[:show])
redirect_to :action => ''list''
end
def update
@show = Show.find(params[:id])
if @show.update_attributes(params[:show])
flash[:notice] = ''Document was successfully updated.''
redirect_to :action => ''list''
else
render :action => ''edit''
end
end
def edit
@show=Show.find(params[:id])
end
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
model.rb file..
def self.save(product)
name =product[''filename''].original_filename
path = File.join("public/data", name)
File.open(path, "wb") { |f|
f.write(product[''filename''].read) }
end
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
new.rhtml....
<% form_tag ({ :action => ''create'' },
{ :multipart => ''true'' }) do%>
<p><label for="show_title">Title</label>:
<%=text_field
''show'',''title''%></p>
<p><label for="book_mobile_name">Mobile
Type</label>:
<%=text_field
''show'',''mobilename''%></p>
<p><label for="book_price">Price</label>:
<%=text_field ''show'',''price''%>
</p>
<p><label
for="book_description">Description</label>:
<%=text_field
''show'',''description''%></p>
<p><label for="book_file">Image</label>:
<%= file_field ''show'', ''filename'' %>
</p>
<%= submit_tag "Send Attachment" %>
<% end %>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
edit.rhtml....
<% form_tag (:action => ''update'', :multipart => true,
:id => @show )do%>
<p><label
for="filename">Description</label><br/>
<%=text_field
''show'',''title''%></p>
<%= file_field ''show'', ''filename''
%></p>
<%= @show.filename%>
<%= hidden_field( :hide, :value => @show.filename )%>
<%= submit_tag "Save changes" %>
<%end %>
<%= link_to ''Back'', {:action => ''list''
} %>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---