Faizymca
........-Это может сработать
if (imgUpload.HasFile)
{
//Check File is available in Fileupload control and then upload to server path
fname = imgUpload.FileName;
//spath = @"~\ImgUpload\" + FileUpload.FileName;
fpath = Server.MapPath("ImgUpload");
fpath = fpath + @"\" + imgUpload.FileName;
string getext = Path.GetExtension(imgUpload.PostedFile.FileName);
string filename = Path.GetFileNameWithoutExtension(imgUpload.PostedFile.FileName);
string strFilePath = filename + DateTime.Now.ToString("yyyyMMdd") + getext;
if (getext != ".JPEG" && getext != ".jpeg" && getext != ".JPG" && getext != ".jpg" && getext != ".png" && getext != ".tif" && getext != ".tiff")
{
Page.ClientScript.RegisterStartupScript(typeof(Page), "successfull", "alert('Please upload only jpeg, jpg,png,tif,tiff'); window.location = 'ParivarRegistration.aspx';", true);
}
else
{
imgUpload.SaveAs(Server.MapPath(@"~\ImgUpload\" + strFilePath));
ImageShow.ImageUrl = @"~\ImgUpload\" + strFilePath;
ViewState["fname"] = fname;
ViewState["fPath"] = @"~\ImgUpload\" + strFilePath;
}
}
else
{
lblMessage.Text = "Please select file!";
}