Hi,
i am trying for uploading multiple files using attachment_fu plugin.
i use MultiSelector javascript for this purpose.It helps me to store
minimum three files before uploading.but when i deleted one file
and replace with another file.the rest of the files including this
files are not save in the database.
i include required javascript files as attachment.
here is my code,
in view
<% form_for :fileindex, :url => { :action => 'create' }, :html => {
:multipart => true } do |f| %>
<%= javascript_include_tag "multifile_compressed"%>
<%= file_field 'file', 'data' %><br>
<div id="files_list">Files (maximum 3):</div>
<script>
var multi_selector = new MultiSelector( document.getElementById(
'files_list' ),3);
multi_selector.addElement( document.getElementById( 'file_data' ) );
</script>
<p><%= f.submit:Create %></p>
<% end %>
in controller:
def create
i = 0
while params['file_'+i.to_s] !="" && !params['file_'+i.to_s].nil?
# puts params['file'+i.to_s]
p = Hash["fileindex"=>{"uploaded_data"=>""}]
# puts p
p["fileindex"]["uploaded_data"] = params["file_"+i.to_s]
# puts p["Fileindex"].size
# if p["Fileindex"].size>0
@fileindex = Fileindex.create! p["fileindex"]
# end
i += 1
end
end
any urgent help is required.
thanks,
Attachments:
http://www.ruby-forum.com/attachment/2841/application.js
--
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---