Click here to Skip to main content
15,905,323 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have to upload multiple files to the (server.mappath)and that code must be in method..how to declare method and functions in ASP.NET
Posted
Updated 18-Jul-11 7:27am
v3
Comments
Manas Bhardwaj 18-Jul-11 5:16am    
any effort?
SruthiGeejula 18-Jul-11 5:20am    
string Filepath= Server.MapPath(@"~\");

HttpFileCollection uploadedFiles = Request.Files;

for (int i = 0; i < uploadedFiles.Count; i++)
{
HttpPostedFile userPostedFile = uploadedFiles[i];

try
{
if (userPostedFile.ContentLength > 0)
{
userPostedFile.SaveAs(Filepath + "\\" +System.IO.Path.GetFileName(userPostedFile.FileName));

}
}
catch (Exception Ex)
{
label1.Text += Ex.Message;
}
}

I have to write the above code in method..i have to call that method instead of writing all the code..

1 solution

Method==> Imageupdate(name.PostedFile,ID,type)


public bool ImageUpdate(HttpPostedFile selectedFile, int ID, string TYPE ) {
}
 
Share this answer
 
Comments
SruthiGeejula 18-Jul-11 5:42am    
this code is for uploading multiple files ?then how sholud i declare a method ?
SruthiGeejula 18-Jul-11 7:01am    
how to declare method for above code ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900