c#多图片上传并生成缩略图的实例代码

2019-05-20 09:45:21于丽

                 {
                     continue;
                 }
                 if (postFile.ContentLength > size)
                 {
                     msg = "文件太大";
                     Page.ClientScript.RegisterStartupScript(GetType(), "", "ValidImage(" + uploadFileID + "," + msg + ")", true);//将提示信息发送到客户端
                     continue;
                 }
                 string savePath = Path.Combine(filePath, postFile.FileName);        //图片的保存地址
                 if (!File.Exists(savePath))
                 {
                     postFile.SaveAs(Path.Combine(filePath, postFile.FileName));     //如果文件不存在就保存
                 }
                 else
                 {
                     msg = "文件" + postFile.FileName + "已经存在";
                     Page.ClientScript.RegisterStartupScript(GetType(), "", "ValidImage(" + uploadFileID + "," + msg + ")", true);//将提示信息发送到客户端
                     continue;
                 }
                 if (IsImg(savePath))            //通过IsImg方法验证文件是否是图片,或者格式是否正确