Wednesday, February 24, 2010

Image Control

private string IMAGEurl(out bool b)
{
string saveLocation = ""; b = false;
string imageurl = "/images/thumbnail/UnknownSuper.gif";
try
{

string imageName = File1.PostedFile.FileName.Substring(File1.PostedFile.FileName.LastIndexOf("\\") + 1);
string extention = File1.PostedFile.FileName.Substring(File1.PostedFile.FileName.LastIndexOf("."));

saveLocation = string.Empty;
saveLocation = Server.MapPath("/images/user");

imageName = txtUsername.Text.ToString() + extention;

saveLocation = saveLocation + "/" + imageName;
// jerry 01-07-2009
Bitmap photo = objvalid.ResizeImage(File1.PostedFile.InputStream, 300, 300);// width height
photo.Save(saveLocation);
//
// File1.PostedFile.SaveAs(saveLocation);

saveLocation = string.Empty;
saveLocation = Server.MapPath("/images/thumbnail");
saveLocation = saveLocation + "/" + imageName;
Bitmap photoFile = objvalid.ResizeImage(File1.PostedFile.InputStream, 64, 64);// width height
photoFile.Save(saveLocation);
if (photoFile.Height > photoFile.Width)
b = true;
imageurl = "/images/thumbnail/" + imageName;
}
catch
{ }
return imageurl;
}

showing using:<img border=0 src=" + thumbImg + " />

No comments:

Post a Comment