Jasny Bootstrap文件上传控件

时间:2012-11-06 03:27:51

标签: c# jquery twitter-bootstrap jasny-bootstrap

我在我的asp.net项目中使用Jasny Bootstrap文件上传控件。

它看起来非常好,但我无法将附件发送到服务器(.ASHX webservice)

我的布局代码如下所示

<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>

1 个答案:

答案 0 :(得分:5)

HTML包含<input type="file" />。您需要设置input元素的name属性。另外,请确保您在表单中使用enctype="multipart/form-data"

<form action="myscript.ashx" method="post" enctype="multipart/form-data">
  <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" name="myupload"/></span>
      <a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
    </div>
  </div>
</form>