Skip to content

Commit 17ffc68

Browse files
author
Nishat
committed
exposed multiple files selection for upload
set the multiple flag to true and modified controller to read the upload data correctly. This change will allow user to select more than one file when they use 'Add Files' button.
1 parent b36a80e commit 17ffc68

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

app/controllers/uploads_controller.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@ def edit
4040
# POST /uploads
4141
# POST /uploads.json
4242
def create
43-
@upload = Upload.new(params[:upload])
43+
# because of multiple flag set to true,
44+
# form post is sending data in slightly nested format
45+
# lets bring this to the front
46+
upload_data = { "upload" => params[:upload]["upload"][0] }
4447

48+
@upload = Upload.new(upload)
4549
respond_to do |format|
4650
if @upload.save
4751
format.html {

app/views/uploads/index.html.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
<span class="btn btn-success fileinput-button">
99
<i class="icon-plus icon-white"></i>
1010
<span>Add files...</span>
11-
<%= f.file_field :upload %>
11+
<!-- because we wish to select more than one files -->
12+
<%= f.file_field :upload, :multiple=>true %>
1213
</span>
1314
<button type="submit" class="btn btn-primary start">
1415
<i class="icon-upload icon-white"></i>

0 commit comments

Comments
 (0)