FileUpload By HTTPPostedFile

HttpPostedFile file2;
HttpFileCollection uploadFilCol;
private bool checkExtension_Large()//to extension for images
{
string strlimg = lblLargeimg.Value;

if (strlimg == "")
{
uploadFilCol = Request.Files;
file2 = uploadFilCol[0];
file2.GetType();

string fileExt2 = Path.GetExtension(file2.FileName).ToLower();
if (fileExt2 == null || fileExt2 == "")
{
return false;
}
else
{
if (fileExt2 == ".gif" || fileExt2 == ".jpg" || fileExt2 == ".jpeg" || fileExt2 == ".png")
{
Session["Largeimg"] = file2.FileName;
lblLargeimg.Value = (string)Session["Largeimg"].ToString();
//lblLargeimg="A Hidden Field"
return true;

}
else
{

return false;
}
}
}
else { return true; }
}



private string uploadLargeimg(string strid)//for uploading large image

{
string fileName = "";
string strLimg = "";

fileName = Path.GetFileName(lblLargeimg.Value);
if (fileName != string.Empty)
{
Random randObj = new Random();
string strName = Path.GetFileNameWithoutExtension(fileName) + "_L_" + randObj.Next(100).ToString() + strid;
string strext = Path.GetExtension(fileName);
file2.SaveAs(Server.MapPath("../Upload_largeimg/") + strName + strext);
strLimg = strName + strext;
}

return strLimg;
}