how to edit uploaded file ???pls help…
i need to update uploaded file or image from directory as well as from
database …
So let me make sure I understand:
-
you want to edit what about a document? Filename? Content-type?
If you want to edit the file itself, I’d think you’d have to download
it, edit it, and then reupload it. -
When you say from directory as well as database, do you mean that
you want to be able to edit a file saved in the filesystem of the
server and a file saved as binary data in the database?
Give us a littl’ more to work with so we can help…
Ron
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%>
Title: <%=text_field 'show','title'%>
Mobile Type: <%=text_field 'show','mobilename'%>
Price: <%=text_field 'show','price'%>
Description: <%=text_field 'show','description'%>
Image: <%= file_field 'show', 'filename' %>
<%= submit_tag "Send Attachment" %> <% end %> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> edit.rhtml....<% form_tag (:action => ‘update’, :multipart => true, :id => @show )do%>
Description
<%=text_field 'show','title'%>