问题描述
我的表格我有3个文件上传控件。一个用于成员图像,另一个用于添加由图像准备,第三个用于pdf文件,它是一个多文件上传控件。我使用javascript创建多个文件上传控件。在编码端获取多个文件我使用代码
HttpFileCollection hfc1 = Request.Files;
for(int i = 0; i< hfc1.Count; i ++)
{
HttpPostedFile img = hfc1.Get(i);
}
当我使用代码时,它会收集所有文件上传控件的值。我只需要第三个文件控制值
< asp:FileUpload ID =fumemrunat =serverCssClass =inputWidth =200px/> ; - >使用jquery上传多个文件
< asp:FileUpload ID =fuprerunat =serverCssClass =inputWidth =200px/>
< asp:FileUpload ID =fuPdfrunat =serverCssClass =inputWidth =200px/>
Im my form i have 3 file upload controls. one for member image,another for adding prepared by image ,and the third on pdf files ,and it is a multiple file upload control .I use javascript to create multiple file upload control .and on coding side for getting multiple files i use the code
HttpFileCollection hfc1 = Request.Files;
for (int i = 0; i < hfc1.Count; i++)
{
HttpPostedFile img = hfc1.Get(i);
}
When i use the code it collect all the file upload controls value. i need only third file control values
<asp:FileUpload ID="fumem" runat="server" CssClass="input" Width="200px" /> ->multiple file upload using jquery
<asp:FileUpload ID="fupre" runat="server" CssClass="input" Width="200px" />
<asp:FileUpload ID="fuPdf" runat="server" CssClass="input" Width="200px" />
推荐答案
<asp:FileUpload ID="fileupload1" runat="server" /> <br />
<asp:FileUpload ID="fileupload2" runat="server" /> <br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Save" />
public void getFiles()
{
HttpPostedFile filecollection = Request.Files [0] as HttpPostedFile;
HttpPostedFile filecollection1 = Request.Files [1] as HttpPostedFile;
}
protected void Button1_Click(对象发送者, EventArgs e)
{
getFiles();
}
public void getFiles()
{
HttpPostedFile filecollection = Request.Files[0] as HttpPostedFile;
HttpPostedFile filecollection1 = Request.Files[1] as HttpPostedFile;
}
protected void Button1_Click(object sender, EventArgs e)
{
getFiles();
}
这篇关于在asp.net中使用不同的文件类型上传多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!