UP_img up_img = new UP_img();
if (FileUpload1.HasFile)
{
string fileContentType = FileUpload1.PostedFile.ContentType;
if (fileContentType == "image/bmp" || fileContentType == "image/gif" || fileContentType == "image/pjpeg")
{
string name = FileUpload1.PostedFile.FileName; // 客户端文件路径
FileInfo file = new FileInfo(name);
string fileName = DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss")+file.Name; // 文件名称
//string fileName_s = "x_" + file.Name; // 缩略图文件名称
//string fileName_sy = "text_" + file.Name; // 水印图文件名称(文字)
//string fileName_syp = "w_" + file.Name; // 水印图文件名称(图片)
string webFilePath = Server.MapPath("../ImgUpload/" + fileName); // 服务器端文件路径
string webFilePath_s = Server.MapPath("../ImgUpload/S_" + fileName); // 服务器端缩略图路径
//string webFilePath_sy = Server.MapPath("ImgUpload/" + fileName_sy); // 服务器端带水印图路径(文字)
string webFilePath_syp = Server.MapPath("../ImgUpload/W_" + fileName); // 服务器端带水印图路径(图片)
string webFilePath_sypf = Server.MapPath("../ImgUpload/water.png"); // 服务器端水印图路径(图片)
try
{
FileUpload1.SaveAs(webFilePath); // 使用 SaveAs 方法保存文件
//AddWater(webFilePath, webFilePath_sy);
up_img.AddWaterPic(webFilePath, webFilePath_syp, webFilePath_sypf);
up_img.MakeThumbnail(webFilePath, webFilePath_s, 130, 130, "W"); // 生成缩略图方法
Response.Write("文件上传成功!");
TextBox_img.Text = fileName;
System.IO.File.Delete(webFilePath);
}
catch (Exception ex)
{
Response.Write("文件上传失败!");
}
}
else
{
Response.Write("文件类型不符!");
}
}
c# 写的智能拼图小游戏
需积分: 10 68 浏览量
2011-03-10
19:25:05
上传
评论 2
收藏 3.96MB RAR 举报
茶卤儿
- 粉丝: 33
- 资源: 4
最新资源
- 探索tecreate:软件开发的未来之星.zip
- 打标机项目C#源码连接扫码
- 基于SSM的房屋租赁系统的设计与实现
- xyctf:从入门到精通的实用指南.zip
- mmqrcode1714153659780.png
- Screenshot_2024-04-27-06-08-58-486_com.baidu.xin.aiqicha.jpg
- 基于Javaweb+Tomcat+MySQL的大学生公寓管理系统+sql文件.zip
- 实训作业基于javaweb的订单管理系统源码+数据库+实训报告.zip
- 多机调度问题贪心算法基于最小堆和贪心算法求解多机调度问题.zip
- 基于同态加密技术的匿名电子投票系统源码.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈