如何上传多个文件jansy-引导文件上传? [英] How to upload multiple files with jansy-bootstrap file upload?

查看:144
本文介绍了如何上传多个文件jansy-引导文件上传?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 jansy引导更换asp.net 文件上传。我已经使用成功检索文件 HttpPostedFile 与此帮助<一个href=\"http://stackoverflow.com/questions/569565/uploading-files-in-asp-net-without-using-the-fileupload-server-control\">answer:

  HttpPostedFile图像= Request.Files [MYFILE];

现在,我该如何让多个文件以选择?随着asp.net 文件上传这是简单地增加了code 的AllowMultiple =真参数,然后后面我只是通过循环:

 的foreach(在FileUpload1.PostedFiles VAR图片)
{...}

我如何做一个自定义的控制?这是我目前的HTML(这是第一图片上传部件示例):

 &LT; D​​IV CLASS =的FileInput的FileInput新数据提供=的FileInput&GT;
    &LT; D​​IV CLASS =fileinput- preVIEW缩略图数据触发=的FileInput的风格=宽度:200像素,高度:150像素;&GT;&LT; / DIV&GT;
    &LT; D​​IV&GT;
        &LT;跨度类=BTN BTN-默认BTN文件&GT;&LT;跨度类=的FileInput新&GT;选择图片&LT; / SPAN&GT;&LT;跨度类=的FileInput-存在&GT;变化与LT; / SPAN&GT ;
          &LT;输入类型=文件ID =MYFILENAME =MYFILE&GT;&LT; / SPAN&GT;
        &LT; A HREF =#类=BTN BTN-默认的FileInput-存在数据解雇=的FileInput&GT;删除&LT; / A&GT;
    &LT; / DIV&GT;
&LT; / DIV&GT;


解决方案

您可以添加多个属性并将其值设置为多个,允许选择多个文件

 &LT;输入类型=文件ID =MYFILENAME =MYFILE多个=多​​&GT;

I'm using jansy bootstrap to replace the asp.net FileUpload. I've successfully retrieved the file using HttpPostedFile with the help of this answer:

HttpPostedFile image = Request.Files["myFile"];

Now, how do I allow multiple files to be selected? With the asp.net FileUpload it was simply adding AllowMultiple="True" parameter and then in the code behind I simply looped through:

foreach (var image in FileUpload1.PostedFiles)
{...}

How do I do this with a custom control? THis is my current html (which is the first Image Upload Widget example):

<div class="fileinput fileinput-new" data-provides="fileinput">
    <div class="fileinput-preview thumbnail" data-trigger="fileinput" style="width: 200px; height: 150px;"></div>
    <div>
        <span class="btn btn-default btn-file"><span class="fileinput-new">Select image</span><span class="fileinput-exists">Change</span>
          <input type="file" id="myFile" name="myFile"></span>
        <a href="#" class="btn btn-default fileinput-exists" data-dismiss="fileinput">Remove</a>
    </div>
</div>

解决方案

You can add multiple attribute and set its value to multiple to allow select of multiple files

<input type="file" id="myFile" name="myFile" multiple="multiple">

这篇关于如何上传多个文件jansy-引导文件上传?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆