62,243
社区成员




//点击上传按钮
protected void Button1_Click(object sender, ImageClickEventArgs e)
{
string fileFullName = string.Empty;
string fileFullNameS = string.Empty;
string timgsrc = string.Empty;
string fileName = DateTime.Now.ToFileTime().ToString();
string exName = Path.GetExtension(this.FileUpload1.FileName);
string filepath = Server.MapPath("~/imgApprove");
string filename_s = "s_" + fileName;
if (exName.ToLower().Equals(".jpg") || exName.ToLower().Equals(".gif") || exName.ToLower().Equals(".png"))
{
//限制大小
if (FileUpload1.FileBytes.Length / (1024.00 * 1024.00) > 1) { message.InnerText = "您上传的图片(" + Math.Round(FileUpload1.FileBytes.Length / (1024.00 * 1024.00), 2) + "M)超过了1M,上传失败!"; return; }
fileFullName = filepath + "//" + fileName + exName;
this.FileUpload1.SaveAs(fileFullName);
timgsrc = fileName + exName;
// 生成缩略图方法
fileFullNameS = filepath + "//" + filename_s + exName;
Share.MakeThumbnail(fileFullName, fileFullNameS, 280, 210, "Cut");
//显示图片
Image.imageUrl="imgApprove/"+timgsrc ;
}
else
{
//Response.Write("<script>alert('图片格式不正确!');</script>");
ClientScript.RegisterStartupScript(this.GetType(), "", "<script>sAlert('图片格式不正确!');</script>");
return;
}
}
//点击上传按钮
protected void Button1_Click(object sender, ImageClickEventArgs e)
{
string fileFullName = string.Empty;
string fileFullNameS = string.Empty;
string timgsrc = string.Empty;
string fileName = DateTime.Now.ToFileTime().ToString();
string exName = Path.GetExtension(this.FileUpload1.FileName);
string filepath = Server.MapPath("~/imgApprove");
string filename_s = "s_" + fileName;
if (exName.ToLower().Equals(".jpg") || exName.ToLower().Equals(".gif") || exName.ToLower().Equals(".png"))
{
//限制大小
if (FileUpload1.FileBytes.Length / (1024.00 * 1024.00) > 1) { message.InnerText = "您上传的图片(" + Math.Round(FileUpload1.FileBytes.Length / (1024.00 * 1024.00), 2) + "M)超过了1M,上传失败!"; return; }
fileFullName = filepath + "//" + fileName + exName;
this.FileUpload1.SaveAs(fileFullName);
timgsrc = fileName + exName;
// 生成缩略图方法
fileFullNameS = filepath + "//" + filename_s + exName;
Share.MakeThumbnail(fileFullName, fileFullNameS, 280, 210, "Cut");
}
else
{
//Response.Write("<script>alert('图片格式不正确!');</script>");
ClientScript.RegisterStartupScript(this.GetType(), "", "<script>sAlert('图片格式不正确!');</script>");
return;
}
}