I have already tried and saved the uploaded files in directory but Not
save it''s path in DB.
this is the error >> Couldn''t find Resource with ID=uploadFile.
this is my controller and view
def uploadFile
@text = params[:upload]
@file=@text[''datafile''].original_filename
name = @file
directory = "public/data"
# create the file path
path = File.join(directory, name)
# write the file
File.open(path, "wb") { |f|
f.write(@text[''datafile''].read) }
redirect_to(:actions=>''new'')
end
------------------------
<%= form_tag ''uploadFile'',:multipart => true %>
<div class="field">
<%= select(:CatID, Resource.SubCategories.collect {|t| [ t.Name,
t.ID ]}, :style=>"width: 400px") %><br/><br/>
<%= label "labeltext","Name" %>
<%= text_field :Name, :style=>"width:400px;" %>
<br/><br/>
</div>
<div class="field">
<%= label "labelDes","Description" %>
<%= text_area :Description,
:style=>"width:400px;height:100px" %>
<br/> <br/>
</div>
Select File : <%= file_field ''upload'',
''datafile''%>
<%= submit_tag "Upload" %>
On Apr 4, 9:29 am, Colin Law
<clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
wrote:> On 3 April 2012 10:42, Sayed G. Farag
<sayed.gama...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > I use Rails 3.2.2 and i created a web application.
> > I want to upload files and save them in assets directory and save its
> > locations in DB.
> > how can i do that?
>
> Start by googling for
> rails file upload
> Then when you see the options and have looked over them come back if
> you need clarifications or recommendations.
>
> Colin
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.