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

2
  • Is this input is in a form? Commented Jul 23, 2019 at 11:57
  • @NN796 Yes its input field to upload file. Commented Jul 23, 2019 at 12:00

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

4 Comments

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. blueimp.github.io/jQuery-File-Upload
@VarinderSohal it should work. Source: stackoverflow.com/questions/17451482/… Can you please post your params in logs after you submit the file?
@VarinderSohal A working JS fiddle jsfiddle.net/nabeeln796/g6mqrbd2
@VarinderSohal is this fixed your problem?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.