日期:2014-05-17 浏览次数:20606 次
//点击上传按钮
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 + e