Here is most simplest way i found while working on .....
U guys no need to google further..I bet it..
create a file called Filename.aspx.cs
write a this code
<asp:Button runat="server" ID="btnupload" Text="Upload"
onclick="btnupload_Click"/> <br/>
<asp:Label runat="server" ID="Label1"></asp:Label>
U guys no need to google further..I bet it..
create a file called Filename.aspx.cs
write a this code
<div>
<input type="file" id="FileUpload1" multiple="multiple" runat="server"/>
<input type="file" id="FileUpload1" multiple="multiple" runat="server"/>
<asp:Button runat="server" ID="btnupload" Text="Upload"
onclick="btnupload_Click"/> <br/>
<asp:Label runat="server" ID="Label1"></asp:Label>
</div>
Filename.aspx.cs
protected void btnupload_Click(object sender, EventArgs e)
{
string tempPath = System.Configuration.ConfigurationManager.AppSettings["FolderPath"];
string savepath = Server.MapPath(tempPath);
for(int i=0;i<Request.Files.Count;i++)
{
HttpPostedFile hpf = Request.Files[i];
string filename = hpf.FileName;
hpf.SaveAs(savepath + @"\" + filename);
}
}
protected void btnupload_Click(object sender, EventArgs e)
{
string tempPath = System.Configuration.ConfigurationManager.AppSettings["FolderPath"];
string savepath = Server.MapPath(tempPath);
for(int i=0;i<Request.Files.Count;i++)
{
HttpPostedFile hpf = Request.Files[i];
string filename = hpf.FileName;
hpf.SaveAs(savepath + @"\" + filename);
}
}
Web.config
<appSettings>
<add key ="FolderPath" value ="uploads"/>
</appSettings >
<appSettings>
<add key ="FolderPath" value ="uploads"/>
</appSettings >
Any Doubts regarding this please do ask...
No comments:
Post a Comment