Karthik Kamalakannan
Karthik Kamalakannan

Reputation: 770

How do I convert HTML tag to Rails tags?

I've been breaking my head to get this working in Rails file tag. I just want to make a file field accept multiple files. For that I need the name to be "attachment[]" instead of "attachment". But for the life of me, I can not figure this out.

How do I convert this simple HTML?

<input type="file" name="attachment[]" id="folderinput" multiple="" directory="" webkitdirectory="" mozdirectory="">

I have this,

<%= file_field_tag :attachment, multiple: true, id: "folderinput", style: "display:none;", "webkitdirectory"=> "", "directory"=> "" %>

Upvotes: 0

Views: 154

Answers (2)

Uday kumar das
Uday kumar das

Reputation: 1613

You can use <%= file_field_tag "attachment", multiple: true, id: "folderinput",name: "attachment[]", style: "display:none;", "webkitdirectory"=> "", "directory"=> "" %>

Upvotes: 0

sdabet
sdabet

Reputation: 18670

How about replacing :attachment by "attachment[]"?

<%= file_field_tag "attachment[]", multiple: true, id: "folderinput", style: "display:none;", "webkitdirectory"=> "", "directory"=> "" %>

Upvotes: 1

Related Questions