Search This Blog

Monday, November 15, 2010

Upload Image File in defined Folder

if (ImageFileUpload.HasFile)
{
try
{
if (ImageFileUpload.PostedFile.ContentType == "image/jpeg")
{
if (ImageFileUpload.PostedFile.ContentLength <>
{
string filename = Path.GetFileName(ImageFileUpload.FileName);
ImageFileUpload.SaveAs(Server.MapPath("~//Images/")+ filename);
UploadErrorlbl.Text = "File Uploaded";
LblFilePath.Text = ImageFileUpload.PostedFile.FileName;
}
else
UploadErrorlbl.Text = "Upload status: Only JPEG files are accepted!";

}
}
catch (Exception ex)
{
UploadErrorlbl.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;

}
}


Also see my other blogs: TreeView using database
                                                                Get Primary key of gridview on edit commant

No comments:

Post a Comment