asp:FileUpload 上次图片
<asp:FileUpload ID="FileUpload附件" runat="server" Width="200px" /> protected void btnEdit_Click(object sender, EventArgs e)
{
if (txtCarPlateNumber.Text.Trim() == "")
{
ClientScript.RegisterStartupScript(GetType(), "", "alert('请输入车牌号!');", true);
return;
}
int Id = 0;
if (string.IsNullOrEmpty(Request.Params["Id"]) == false)
{
Id = int.Parse(Request.Params["Id"]);
}
ModelBlackWhiteList model = new ModelBlackWhiteList();
model.Id = Id;
model.CarPlateType = ddlCarPlateType.SelectedItem.Text;
model.CarPlateNumber = txtCarPlateNumber.Text.Trim();
model.Company = txtCompany.Text.Trim();
model.BWFlag = ddlBWFlag.SelectedItem.Value;
model.OperatorName = this.UserLogin;
model.CreateDateTime = DateTime.Now; string CommandName = Request.Params["CommandName"].ToString();
switch (CommandName)
{
case "Upd":
{
if (FileUpload附件.PostedFile.FileName.Trim().Length != 0)
{
string savePath;
string fileName = DateTime.Now.ToString("yyyyMMddHHmmssms");
if (FileUpload附件.HasFile && FileUpload附件.PostedFile.FileName.Contains(".jpg"))
{
savePath = Server.MapPath("~/Upload/");//指定上传文件在服务器上的保存路径
//检查服务器上是否存在这个物理路径,如果不存在则创建
if (!System.IO.Directory.Exists(savePath))
{
System.IO.Directory.CreateDirectory(savePath);
}
savePath = savePath + fileName + ".jpg";
FileUpload附件.SaveAs(savePath);
model.CarPicPath = "/Upload /" + fileName + ".jpg";
}
else
{
ClientScript.RegisterStartupScript(GetType(), "", "alert('请选择JPG图片文件!');", true);
return;
}
}
int result = SqlSugarClientHelper.SqlDBConnection.Updateable<ModelBlackWhiteList>(model).ExecuteCommand();
if (result > 0)
{
ClientScript.RegisterStartupScript(GetType(), "", "alert('保存成功!');window.location = 'BlackWhiteListManage.aspx';", true);
}
else
{
ClientScript.RegisterStartupScript(GetType(), "", "alert('保存失败!');", true);
}
break;
}
case "New":
{
if (FileUpload附件.PostedFile.FileName.Trim().Length != 0)
{
string savePath;
string fileName = DateTime.Now.ToString("yyyyMMddHHmmssms");
if (FileUpload附件.HasFile && FileUpload附件.PostedFile.FileName.Contains(".jpg"))
{
savePath = Server.MapPath("~/Upload/BWFLag/");//指定上传文件在服务器上的保存路径
//检查服务器上是否存在这个物理路径,如果不存在则创建
if (!System.IO.Directory.Exists(savePath))
{
System.IO.Directory.CreateDirectory(savePath);
}
savePath = savePath + fileName + ".jpg";
FileUpload附件.SaveAs(savePath);
model.CarPicPath = "/Upload/BWFLag/" + fileName + ".jpg";
}
else
{
ClientScript.RegisterStartupScript(GetType(), "", "alert('请选择JPG图片文件!');", true);
return;
}
}
int result = SqlSugarClientHelper.SqlDBConnection.Insertable<ModelBlackWhiteList>(model).ExecuteCommand();
if (result > 0)
{
ClientScript.RegisterStartupScript(GetType(), "", "alert('保存成功!');window.location = 'BlackWhiteListManage.aspx';", true);
}
else
{
ClientScript.RegisterStartupScript(GetType(), "", "alert('保存失败!');", true);
}
break;
}
}
}
asp:FileUpload 上次图片的更多相关文章
- js实现FileUpload选择图片后预览功能
当asp.net的FileUpload选择一个图片后不需要上传就能显示出图片的预览功能, 代码: <%@ Page Language="C#" AutoEventWireup ...
- C# asp:FileUpload上传文件使用JS实现预览效果
js代码: <script type="text/javascript"> //下面用于图片上传预览功能 function setImagePreview() { va ...
- asp.net实现图片在线上传并在线裁剪
1.说明 接上一篇文章uploadify实现多附件上传完成后,又突然用到头像上传并在线裁剪.在网上找个众多例子都没有符合要求的,有一篇文章写的不错,就是文旺老兄写的这篇Asp.Net平台下的图片在线裁 ...
- ASP.NET MVC图片管理(上传,预览与显示)
先看看效果(下面gif动画制作有点大,5.71MB): 题外话:上面选择图片来源于Insus.NET的新浪微博:http://weibo.com/104325017 也是昨晚(2015-07-03)I ...
- ASP.NET MVC图片管理(更新)
Insus.NET在ASP.NET MVC专案中,实现了图片管理,上传,预览,显示,删除等功能,还差一个功能,就是更新图片的功能,那这次来完成它.你可以先参考前2篇<ASP.NET MVC图片管 ...
- ASP.NET MVC图片管理(删除)
上星期有写了一篇<ASP.NET MVC图片管理(上传,预览与显示)>http://www.cnblogs.com/insus/p/4620420.html 它只实现了上传功能,即时预览以 ...
- <asp:FileUpload>控件 获取不到文件名
<asp:FileUpload>控件 放在了<asp:UpdatePanel>控件中会导致获取不到文件名.
- asp:FileUpload 控件上传多文件
<asp:FileUpload runat="server" ID="imgUpload" AllowMultiple="true" ...
- ASP.NET(C#)图片加文字、图片水印,神啊,看看吧
ASP.NET(C#)图片加文字.图片水印 一.图片上加文字: //using System.Drawing; //using System.IO; //using System.Drawing.Im ...
随机推荐
- 手把手教你如何安装和使用Karma-Jasmine
注意:本文中出现的资料链接.karma的插件安装等,均可能需要翻$墙后才能正确执行. Jasmine是一个Javascript的测试工具,在Karma上运行Jasmine可完成Javascript的自 ...
- Yarn 和 Npm 命令行切换 摘录
原文作者: @Gant Laborde原文地址: https://shift.infinite.red/np...中文翻译: @文蔺译文地址:http://www.wemlion.com/2016/n ...
- css设置:图片文字等不能被选择
-webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;
- Selenium Web自动化 原理
文章转自 白月黑羽教Python 原理 说到web应用自动化测试,第一选择就是 Selenium 框架. Selenium 是一个 Web 应用的自动化框架. 通过它,我们可以写出自动化程序像人一样( ...
- springcloud-01-介绍
跟随springcloud的一套视频学习springcloud, 把学到的记录下来, 方便自己, 方便别人 IDE: idea 一个父工程, 其他均为module 父工程的依赖: <parent ...
- springboot-10-前端页面整合, thymeleaf, freemarker, jsp 模板使用
springboot 中不建议使用jsp作为页面展示, 怎么使用可以看: http://412887952-qq-com.iteye.com/blog/2292471 关于什么是thymeleaf, ...
- 使用Visual Studio Code搭建PHP调试环境
1.需要安装的软件 Visual Studio Code. WAMP(包括Apache.MySQL.PHP.以及最关键的XDebug) 2.下载软件 Visual Studio Code,光看名字就知 ...
- 【云+社区极客说】新一代大数据技术:构建PB级云端数仓实践
本文来自腾讯云技术沙龙,本次沙龙主题为构建PB级云端数仓实践 在现代社会中,随着4G和光纤网络的普及.智能终端更清晰的摄像头和更灵敏的传感器.物联网设备入网等等而产生的数据,导致了PB级储存的需求加大 ...
- oracle = : := 和变量绑定 oracle通配符和运算符
这篇是7788凑的:":="是赋值语句 如: l_name :='sky';..."=" 是判断是否相等. 如: if 1=1 then...":&q ...
- linux下在线升级nodejs
因现有项目需要用一个截屏node包,此包必须新版本,所以紧急升级下测试环境nodejs,后续再升级线上,小小试了下node在线升级 方案1,使用npm安装n模块,使用n来升级nodejs 首先要知道n ...