Coolite.Ext.Web.FileUploadField uploadControl = ((Coolite.Ext.Web.FileUploadField)this.tbMain.FindControl(ControlsID.imageUpload));
//图片路径
string strFileName = uploadControl.FileName;
DateTime Now = DateTime.Now;
string FileName = "Parts" + Now.ToString("yyyyMMddHHmmssffff");
string FilePath = "~/UploadFile/ConstructImage/" + FileName + System.IO.Path.GetExtension(strFileName);
try
{
System.Web.HttpFileCollection _files = System.Web.HttpContext.Current.Request.Files;
for (System.Int32 _iFile = 0; _iFile < _files.Count; _iFile++)
{
System.Web.HttpPostedFile _postedFile = _files[_iFile];
if (!string.IsNullOrEmpty(FilePath))
{
if (System.IO.File.Exists(System.Web.HttpContext.Current.Request.MapPath(FilePath)))
{
File.Delete(System.Web.HttpContext.Current.Request.MapPath(FilePath));
}
_postedFile.SaveAs(System.Web.HttpContext.Current.Request.MapPath(FilePath));
}
}
}
catch
{
Coolite.Ext.Web.MessageBox.Config configError = new Coolite.Ext.Web.MessageBox.Config();
configError.Title = "上传状态";
configError.Message = "文件上传有错误,请检查!";
configError.Buttons = Coolite.Ext.Web.MessageBox.Button.OK;
configError.Icon = Coolite.Ext.Web.MessageBox.Icon.ERROR;
Coolite.Ext.Web.Ext.Msg.Show(configError);
return;
}
Coolite.Ext.Web.Image uploadImage = ((Coolite.Ext.Web.Image)this.tbMain.FindControl(ControlsID.uploadImage));
uploadImage.ImageUrl = FilePath;
this.ImageUrl = @"http://" + Request.Url.Host + ":" + Request.Url.Port.ToString() + Request.ApplicationPath + FilePath.Replace("~", string.Empty);
Session.Add("imageUrl", ImageUrl.ToString());
Coolite.Ext.Web.MessageBox.Config config = new Coolite.Ext.Web.MessageBox.Config();
config.Title = "上传状态";
config.Message = "上传成功";
config.Buttons = Coolite.Ext.Web.MessageBox.Button.OK;
config.Icon = Coolite.Ext.Web.MessageBox.Icon.INFO;
Coolite.Ext.Web.Ext.Msg.Show(config);