public void UploadFile(object sender , EventArgs E) { //check if the fileposted is bot null if(myFile.PostedFile!=null) { //some string manipulations to extract the filename from the full file path string nam = myFile.PostedFile.FileName ; int i= nam.LastIndexOf("\\") ; string newnm =nam.Substring(i) ; //save the file to the destination path on your server //change this path as per your needs (remember the path you specify should exist and have 'write' access) //Note: I have used "c:\\" etc the "\\" is because I have to give a escape character //in a string myFile.PostedFile.SaveAs("c:\\inetpub\\wwwroot\\upload\\"+newnm) ;
//Get the various properties of the Uploaded file fname.Text=myFile.PostedFile.FileName; fenc.Text=myFile.PostedFile.ContentType ; fsize.Text=myFile.PostedFile.ContentLength.ToString(); } }
{
//check if the fileposted is bot null
if(myFile.PostedFile!=null)
{
//some string manipulations to extract the filename from the full file path
string nam = myFile.PostedFile.FileName ;
int i= nam.LastIndexOf("\\") ;
string newnm =nam.Substring(i) ; //save the file to the destination path on your server
//change this path as per your needs (remember the path you specify should exist and have 'write' access)
//Note: I have used "c:\\" etc the "\\" is because I have to give a escape character
//in a string
myFile.PostedFile.SaveAs("c:\\inetpub\\wwwroot\\upload\\"+newnm) ;
//Get the various properties of the Uploaded file
fname.Text=myFile.PostedFile.FileName;
fenc.Text=myFile.PostedFile.ContentType ;
fsize.Text=myFile.PostedFile.ContentLength.ToString();
}
}