Dynamically add Upload button, upload multiple files

Source: Internet
Author: User
Tags httpcontext
Upload Multiple files <script language= "javascript" type= "Text/javascript" >
function Faddattach () {
var gattchhtml= ' <div class= "Qrle text2" > Accessories: </div><div class= "le" ><input type= "file" runat= " Server "Name=" attachfile[] "class=" bot3 "></div><div class=" le "><input type=" button "Name=" Submit " value= "Delete" "class=" Bot2 "id=" Btndeletereadattach "/></div><span></span>";
var Attach=document.getelementbyid ("Dvreadattach");
var spnlist=attach.getelementsbytagname ("SPAN");
var spn=document.createelement ("DIV");
Spn.classname= "QRC4";
spn.innerhtml=gattchhtml;
Spn.childnodes[1].childnodes[0].name= "attachfile[]" + spnlist.length;
Attach.appendchild (SPN); Increase gattchhtml
Fgetobjinputbyid (SPN, "Btndeletereadattach"). () {Fdeleteattach (this);};
document.getElementById ("Aaddattach"). Innerhtml= "Continue to add attachments";
Attach.style.display= "";
if (spnlist.length>1) {
Spn.childnodes[0].innerhtml= "&nbsp;&nbsp;&nbsp;";
}
}
function Fgetobjinputbyid (obj,id) {
var inputlist=obj.getelementsbytagname ("INPUT");
for (Var i=0;i<inputlist.length;i++) {
if (Inputlist[i].id==id) {
return inputlist[i];
}
}
return null;
}
function Fdeleteattach (obj) {
try{
Obj.parentNode.parentNode.parentNode.removeChild (Obj.parentNode.parentNode);
var Attach=document.getelementbyid ("Dvreadattach");
var spnlist=attach.getelementsbytagname ("SPAN");
if (spnlist.length==0) {
document.getElementById ("Aaddattach"). Innerhtml= "Add Attachments";
Attach.style.display= "None";
}else{
document.getElementById ("Aaddattach"). Innerhtml= "Continue to add attachments";
}
}catch (exp) {
Fdebug ("Fdeleteattach", exp.description);
}
}

</script>

<a href= "Javascript:faddattach ();" id= "Aaddattach" > Add attachment </a><div id= "Dvreadattach" Display: None ">
</div> <asp:button id= "Button1" runat= "Server" text= "button"/>

httpfilecollection files = HttpContext.Current.Request.Files;

for (int i = 0; i < HttpContext.Current.Request.Files.Count; i++)
{
Httppostedfile hp = (httppostedfile) httpcontext.current.request.files[i];
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.