如何在两个fileupload控件中使用多个文件上载 [英] How to use multiple file upload in two fileupload control
本文介绍了如何在两个fileupload控件中使用多个文件上载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$(document).ready1(function () {
// up to 3 files can be selected
// invoke plugin
$('#ctl00_ContentPlaceHolder1_flpProspectus').MultiFile(5);
// if you send in a number the plugin
// will treat it as the file limit
});
$(document).ready2(function () {
// up to 3 files can be selected
// invoke plugin
$('#ctl00_ContentPlaceHolder1_flpEnquiry').MultiFile(5);
// if you send in a number the plugin
// will treat it as the file limit
});
<asp:FileUpload ID="flpProspectus" class="form-control" runat="server" Style="width: 50%; margin-top: -50px;float:left; margin-left:90%" />
<asp:FileUpload ID="flpEnquiry" class="form-control" runat="server" Style="width: 50%; margin-top: -50px;float:left; margin-left:90%" />
Cs页码---
Cs Page code---
public void FileUpload1()
{
if (flpOrientation.HasFile)
{
string fileExtension = System.IO.Path.GetExtension(flpProspectus.FileName);
int fileSize = flpProspectus.PostedFile.ContentLength;
HttpFileCollection hfc = Request.Files;
string[] arr = new string[5];
for (int i = 0; i < hfc.Count; i++)
{
HttpPostedFile hpf = hfc[i];
if (hpf.ContentLength > 0)
{
hpf.SaveAs(Server.MapPath("~/college/fileupload3/") + System.IO.Path.GetFileName(hpf.FileName));
string filepath = Server.MapPath("~/college/fileupload3/");
string path = "college/fileupload3/" + hpf.FileName;
if (i < 5)
{
arr[i] = path;
path1 = arr[0]; path2 = arr[1]; path3 = arr[2]; path4 = arr[3]; path5 = arr[4];
}
}
}
}
}
我尝试过:
以上我提到代码 -
我想要知道当我从FileUpload控件中选择文件时它工作正常
但是当我从第一个文件控件中选择一个文件而从第二个FileUpload控件中选择一个文件然后两个文件都存储在同一个文件夹和我的循环中条件工作两个控件所以如何解决这个问题,当我选择第一个FileUpload控件然后我的循环条件只工作第一控制所以请帮助我 -
我正在使用文件上传此链接的代码 -
jQuery MultiFile v2。 2.1 [ ^ ]
推荐答案
( doc ument )。ready1( function (){
// 最多可选择3个文件
// 调用插件
(document).ready1(function () { // up to 3 files can be selected // invoke plugin
(' # ctl00_ContentPlaceHolder1_flpProspectus')。MultiFile( 5 );
// 如果你发送一个数字插件
// 将其视为文件限制
});
('#ctl00_ContentPlaceHolder1_flpProspectus').MultiFile(5); // if you send in a number the plugin // will treat it as the file limit });
( document )。ready2( function (){
// 最多可选择3个文件
// 调用插件
(document).ready2(function () { // up to 3 files can be selected // invoke plugin
这篇关于如何在两个fileupload控件中使用多个文件上载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文