日期:2014-05-18 浏览次数:20483 次
if (type == "jpg" || type == "JPG" || type == "gif" || type == "GIF" || type == "BMP" || type == "bmp" || type == "png") //判断是否为图片类型
{
if (this.FileUpload1.PostedFile.ContentLength > 200 * 1024)
{
Response.Write("<script>alert('上传图片必须小于50k!');</script>");
return "";
}
else
{
string path = "D:\\wwwroot\\CCMTV\\HuoDong\\angel\\".ToString(); //本地上传路径
//string path = "E:\\kaoshi\\".ToString(); //获取上传文件的外网站发布
fileName1 = "AmyShow/" + DateTime.Now.ToString("yyyyMMddhhmmss") + fileName.ToString();
if (File.Exists("D:\\wwwroot\\CCMTV\\HuoDong\\angel\\AmyShow\\" + fileName1))//(这个地方做判断是不是 有这 张图片如果已经有图片 则不能上传 )
{
return "";
}
else
{
fileName1 = "AmyShow/" + DateTime.Now.ToString("yyyyMMddhhmmss") + fileName.ToString();
this.FileUpload1.SaveAs(path + fileName1);//存储文件到磁盘
// this.newPreview.InnerText. = "~/admin/img/" + fileName;//显示图片
// this.newPreview.InnerHtml = "~/admin/img/" + fileName;//显示图片
}
}
/AmyShow/