0

I am working on a live project and there is a requirement to upload only one file and then forced to a user to submit the form.

%input#primary-file-uploads{type: "file", name: "upload[upload]", class: "file-input"}

I removed multiple:"multiple" attribute from input tag but it's still uploading multiple files. how can I approach it to complete my task

Varinder Sohal
  • 1,142
  • 5
  • 24
  • 44

1 Answers1

1

I think you should try this: %input#primary-file-uploads{type: "file", name: "upload", class: "file-input"}

I think upload[upload] is forcing it to take multiple files. Source

A guide present to upload a single file. And here is a working JSFiddle.

By the way, you can use remotipart gem

NN796
  • 1,247
  • 11
  • 31
  • I tried with your code but now it's not uploading a single file and I am restricted to use jquery file upload not want to use any other gem. https://blueimp.github.io/jQuery-File-Upload/ – Varinder Sohal Jul 23 '19 at 12:14
  • @VarinderSohal it should work. Source: https://stackoverflow.com/questions/17451482/blueimp-file-upload-single-file-upload Can you please post your params in logs after you submit the file? – NN796 Jul 23 '19 at 12:20
  • @VarinderSohal A working JS fiddle http://jsfiddle.net/nabeeln796/g6mqrbd2/ – NN796 Jul 23 '19 at 12:27
  • @VarinderSohal is this fixed your problem? – NN796 Jul 26 '19 at 07:48