FileUpload using FileInformation

private string uploadSmallimg(string strid, string strLimage)//for uploading small image

//strLimage= File name
{
string fileName = "";
string strSimg = "";
if (strLimage != string.Empty)
{
string strExist = Server.MapPath("../Upload_largeimg/") + strLimage; //Server.MapPath("../Upload_largeimg") + "\\" + strLimage;
Random randObj = new Random();
string strName = Path.GetFileNameWithoutExtension(fileName) + "_S_" + randObj.Next(100).ToString() + strid;
string strext = Path.GetExtension(strLimage);
System.Drawing.Image imgPhotoVert = System.Drawing.Image.FromFile(strExist);
imgPhotoVert = FixedSize(imgPhotoVert, 135, 158, "s");
imgPhotoVert.Save(Server.MapPath("../Upload_smallimg") + "/" + strName + strext);
strSimg = strName + strext;
}
return strSimg;
}





static System.Drawing.Image FixedSize(System.Drawing.Image imgPhoto, int Width, int Height, string size)

{
int sourceWidth = imgPhoto.Width;
int sourceHeight = imgPhoto.Height;
int sourceX = 0;
int sourceY = 0;
int destX = 0;
int destY = 0;
float nPercent = 0;
float nPercentW = 0;
float nPercentH = 0;

nPercentW = ((float)Width / (float)sourceWidth);
nPercentH = ((float)Height / (float)sourceHeight);

//if we have to pad the height pad both the top and the bottom
//with the difference between the scaled height and the desired height

if (nPercentH < nPercentW)
{
nPercent = nPercentH;
destX = (int)((Width - (sourceWidth * nPercent)) / 2);
}
else
{
nPercent = nPercentW;
destY = (int)((Height - (sourceHeight * nPercent)) / 2);
}
int destWidth, destHeight;
if (size == "m")
{
destWidth = (int)(sourceWidth * nPercent);
destHeight = (int)(sourceHeight * nPercent);
}
else
{
destWidth = 135;
destHeight = 158;
}

Bitmap bmPhoto = new Bitmap(destWidth, destHeight);

bmPhoto.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution);

Graphics grPhoto = Graphics.FromImage(bmPhoto);
grPhoto.InterpolationMode = InterpolationMode.HighQualityBicubic;
Point a = new Point(0);
Size s = new Size(destWidth, destHeight);
grPhoto.DrawImage(imgPhoto,
new Rectangle(a, s),
new Rectangle(sourceX, sourceY, sourceWidth, sourceHeight),
GraphicsUnit.Pixel);
grPhoto.Dispose();
return bmPhoto;
}