zoukankan
html css js c++ java
.NET上传单张图片代码
//
上传图片
protected
void
Button4_Click(
object
sender, EventArgs e)
{
Random rad
=
new
Random();
string
pathname
=
Server.MapPath(
"
img/
"
);
//
要保存到的文件夹
string
filename
=
FileUpload1.FileName;
//
选中的图片名
string
filepath
=
DateTime.Now.Millisecond
+
rad.Next().ToString()
+
filename;
//
要保存的图片名
int
filesize
=
FileUpload1.PostedFile.ContentLength;
//
图片大小
string
filetype
=
filename.Substring(filename.LastIndexOf(
"
.
"
)
+
1
);
//
图片后缀
if
((filetype
==
"
jpg
"
||
filetype
==
"
jpeg
"
||
filetype
==
"
gif
"
))
{
//
文件大小要小于200k
if
(filesize
<
200000
)
{
FileUpload1.PostedFile.SaveAs(Server.MapPath(
"
~/img/
"
)
+
filepath);
Image1.ImageUrl
=
"
~/img/
"
+
filepath;
//
用image控件显示一下图
TextBox7.Text
=
"
~/img/
"
+
filepath;
//
把图片地址保存到图片地址框中
}
else
{
TextBox7.Text
=
"
图片超过100K了!
"
;
}
}
else
{
TextBox7.Text
=
"
不能上传这种格式的图片!
"
;
}
TextBox8.Focus();
//
聚焦到下一个输入框
}
查看全文
相关阅读:
CAP.dll of dotnetcore
GRPC 高性能 RPC 框架, 服务间通讯
REST Client
ERP Export
ERP Update DataSource
knockout js
面试题目总结
JavaScript Objiects and Prototypes
PLS-00172: string literal too long
字符串连接性能
原文地址:https://www.cnblogs.com/kingfly/p/1572780.html
最新文章
wkid=4326, 4490,cgcs2000,坐标系总结(高德爬取的坐标叠加到84上是什么样)
arcpy 生成等时圈isochron
arcpy修改mxd symbology.classBreakLabels
SQL SERVER-单用户数据库
SQLSERVER-事务日志作用
SQL SERVER-日志增长原因定位
Go-值类型和引用类型
Go-defer
Go-数组二维数组
Go-捕获异常
热门文章
Go-二分查找
Go-冒泡排序
Go-map
angular项目集成tinymce富文本输入框
jenkins build 报错: mvn: command not found 解决
jenkins 插件更改国内源
go 依赖注入
go的web框架gin实现jsonp跨域
获取RabbitMQ消息发送确认Acks的DeliveryTag对应的消息内容
.net core 基于 IdentityServer4 创建授权与验证服务
Copyright © 2011-2022 走看看