<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default3.aspx.vb" Inherits="Default3" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Test - file upload trick</title> <script type="text/javascript"> function CallUpload() { if(document.getElementById("FileUpload1").value=='') { document.getElementById("FileUpload1").click(); } else if(document.getElementById("FileUpload2").value=='') { document.getElementById("FileUpload2").click(); } else if(document.getElementById("FileUpload3").value=='') { document.getElementById("FileUpload3").click(); } return false; } function AddToList(evt) { var myOption; myOption = document.createElement("Option"); myOption.text = evt; myOption.value = evt; document.getElementById("lstFiles").add(myOption); } </script> </head> <body> <form id="form1" runat="server"> <div> <br /> add upto 3 files<br /> <asp:FileUpload ID="FileUpload1" runat="server" Width="514px" onchange="javascript:AddToList(this.value);" style="display:none;"/> <asp:LinkButton ID="q0" runat="server" Text="link1" OnClientClick="return CallUpload();"></asp:LinkButton> <br /> <asp:FileUpload ID="FileUpload2" runat="server" Width="514px" onchange="javascript:AddToList(this.value);" style="display:none;"/> <br /> <asp:FileUpload ID="FileUpload3" runat="server" Width="514px" onchange="javascript:AddToList(this.value);" style="display:none;"/> <br /> <asp:ListBox ID="lstFiles" runat="server" Width="221px"></asp:ListBox> <br /> <br /> <asp:Button ID="Upload" runat="server" Text="Button" /> <br /> </div> </form> </body> </html>
---------------------------In Code ------------------
Protected Sub Upload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Upload.Click If Not FileUpload1.PostedFile.FileName = "" Then FileUpload1.PostedFile.SaveAs("file save path goes here") End If If Not FileUpload2.PostedFile.FileName = "" Then FileUpload2.PostedFile.SaveAs("file save path goes here") End If If Not FileUpload3.PostedFile.FileName = "" Then FileUpload3.PostedFile.SaveAs("file save path goes here") End If End Sub