[英]How to upload multiple files using ASP.Net and Jquery…?
我在aspx頁面中添加了以下javascripts ...
<script src="jquery-1.3.2.js" type="text/javascript"></script>
<script src="jquery.MultiFile.js" type="text/javascript"></script>
我還在按鈕單擊操作中添加了以下代碼。
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/>");
}
}
問題是我無法選擇多重文件... !!!
<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/
只是使其倍數
<asp:FileUpload id="FileUploadControl" Multiple="Multiple" class="multi" runat="server"/>
您應該使用AjaxFileUpload而不是文件上傳。 這是一個ajax控件工具包組件。 之后,您將創建將獲取每個文件的事件。 它已上傳並為您提供了文件已上傳的鏈接。
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<ajaxToolkit:AjaxFileUpload ID="AjaxFileUpload1"
ThrobberID="myThrobber"
ContextKeys="Vinicius"
AllowedFileTypes="jpg,jpeg"
MaximumNumberOfFiles=10
runat="server"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.