62,046
社区成员
发帖
与我相关
我的任务
分享
protected void Button1_Click(object sender, EventArgs e)
{
String Str = this.FileUpload1.PostedFile.FileName;
String PicName = Str.Substring(Str.LastIndexOf("\\") + 1);
String PicPath = "Tupian\\" + PicName;
String path = Server.MapPath(PicPath);
FileUpload1.SaveAs(path);
//文件上传没有问题
String NewPicName = "c_" + PicName; //新图名
String NewPicPath = "Tupian\\" + NewPicName;
String NewPath = Server.MapPath(NewPicPath); //新图存储路径
//下面这行代码肯定有问题,就是不知道哪有问题
int intHeight = 40;
Bitmap objPic = new Bitmap(Str); //Str是原图地址
int intWidth = (intHeight / objPic.Height) * objPic.Width;
Bitmap objNewPic = new Bitmap(objPic,intWidth,intHeight);
objNewPic.Save(NewPath);