javascript 如何使用 ASP.Net 和 Jquery 上传多个文件...?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22110117/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 22:27:45  来源:igfitidea点击:

How to upload multiple files using ASP.Net and Jquery...?

c#javascriptjqueryasp.netfile-upload

提问by Dineshkumar Ponnusamy

I have added the following javascripts in my aspx page...

我在我的 aspx 页面中添加了以下 javascripts...

<script src="jquery-1.3.2.js" type="text/javascript"></script>
<script src="jquery.MultiFile.js" type="text/javascript"></script>

I have also added the following code in the button click operation.

我还在按钮单击操作中添加了以下代码。

 HttpFileCollection hfc = Request.Files;
    for (int i = 0; i < hfc.Count; i++)
    {
        HttpPostedFile hpf = hfc[i];
        if (hpf.ContentLength > 0)
        {
            hpf.SaveAs(Server.MapPath("MyFiles") + "\" + System.IO.Path.GetFileName(hpf.FileName));
            Response.Write("<b>File: </b>" + hpf.FileName + " <b>Size:</b> " + hpf.ContentLength + " <b>Type:</b> " + hpf.ContentType + " Uploaded Successfully <br/>");
        }
    }

The problem is I can't select mulltiple files...!!!

问题是我不能选择多个文件...!!!

 <asp:FileUpload id="FileUploadControl" class="multi" runat="server"/>
        <asp:Button ID="BtnUpload" runat="server" onclick="BtnUpload_Click" 
            Text="Upload" Width="105px" style="margin-top: 4px" />
        <asp:Label runat="server" id="StatusLabel" text="Upload status: " />

http://www.c-sharpcorner.com/UploadFile/prathore/multiple-file-upload-using-jquery-in-Asp-Net-3-5/

http://www.c-sharpcorner.com/UploadFile/prathore/multiple-file-upload-using-jquery-in-Asp-Net-3-5/

采纳答案by COLD TOLD

just make it multiple

把它变成多个

<asp:FileUpload id="FileUploadControl" Multiple="Multiple" class="multi" runat="server"/>

回答by VINICIUS SIN

you should use AjaxFileUpload instead of file upload. This is an ajax control toolkit component. After that you create the event that will get each file. It alredy uploads and give to you the link that the file was uploaded.

您应该使用 AjaxFileUpload 而不是文件上传。这是一个ajax控件工具包组件。之后,您创建将获取每个文件的事件。它已经上传并给你文件上传的链接。

    <%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>

  <ajaxToolkit:AjaxFileUpload ID="AjaxFileUpload1"
    ThrobberID="myThrobber"
    ContextKeys="Vinicius"
    AllowedFileTypes="jpg,jpeg"
    MaximumNumberOfFiles=10
    runat="server"/>