如何使用Jasny文件上传获取文件位置

时间:2012-10-29 08:54:04

标签: twitter-bootstrap jasny-bootstrap

我想将文件位置传递给我的控制器我在这里每个元素都使用data-bind ="value: x"但是没有可用我无法捕获文件位置。

我正在使用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 个答案:

答案 0 :(得分:3)

如果您发布了整个表单,将会很有帮助 我一开始一直在努力设置,只是意识到我所要做的就是在表单中设置:multipart => true

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

一旦这样做,您应该能够获得控制器中的文件路径。我不确定这是否可以解决您的问题。同样,如果您在提交表单时显示更多代码以及当前在params中获得的内容,将会有所帮助。

答案 1 :(得分:0)

在不同的帖子中查看相同的问题和一些答案: jQuery Ajax File Upload

@Adeel的帖子解决了我的需求。