How to get File Location using Jasny File Upload

2k Views Asked by At

I wanted to pass the File Location to my Controller I have been using data-bind ="value: x" on each element here but to no available I can't catch the file location.

I'm using this script from Jasny Bootstrap FileUpload

<div class="fileupload fileupload-new" data-provides="fileupload">
  <div class="input-append">
    <div class="uneditable-input span3"><i class="icon-file fileupload-exists"></i> 
<span class="fileupload-preview"></span></div><span class="btn btn-file">
<span class="fileupload-new">Select file</span><span class="fileupload-exists">Change</span>
<input type="file" /></span><a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
  </div>
</div>
2

There are 2 best solutions below

0
On

Check out same question with some answers on a different post: jQuery Ajax File Upload

The post by @Adeel solved my needs.

1
On

It would be helpful if you posted your entire form.
I have been struggling with the setup at first only to realize that all I had to do was set :multipart => true in the form.

<%= form_for @item, :html => {:multipart => true} do |f| %>

Once you do that, you should be able to get the file path in the controller. I am not sure if that is a solution to your problem though. Again, it would help if you showed more code and what you are currently getting in the params when you submit the form.