ASP.NET中使用FileUpload上传文件怎么将上传文件的路径保存到数据库中
发布网友
发布时间:2022-04-23 04:43
我来回答
共2个回答
热心网友
时间:2022-04-23 06:12
给你一个类,找添加FileUpload的id就能上传
并且会有你可能想要的。
#region
图片上传
private
static
string
_MSG;
private
string
_ofullname
=
"0";
private
string
_tfullname
=
"0";
private
string
_ofilename
=
"0";
private
string
_tfilename
=
"0";
private
int
_limitwidth
=
3072;
private
int
_limitheight
=
2304;
private
int
_twidth
=
100;
private
int
_theight
=
100;
private
int
_size
=
3000000;
private
bool
_israte
=
true;
private
string
_path
=
"Images/CardUpload";
///
<summary>
///
信息
///
</summary>
public
static
string
MSG
{
get
{
return
_MSG;
}
set
{
_MSG
=
value;
}
}
///
<summary>
///
保存时的完整路径.原图
///
</summary>
public
string
OFullName
{
get
{
return
_ofullname;
}
set
{
_ofullname
=
value;
}
}
///
<summary>
///
保存时的完整路径.缩略图
///
</summary>
public
string
TFullName
{
get
{
return
_tfullname;
}
set
{
_tfullname
=
value;
}
}
///
<summary>
///
保存时的图片名称.原图
///
</summary>
public
string
OFileName
{
get
{
return
_ofilename;
}
set
{
_ofilename
=
value;
}
}
///
<summary>
///
保存时的图片名称.缩略图
///
</summary>
public
string
TFileName
{
get
{
return
_tfilename;
}
set
{
_tfilename
=
value;
}
}
///
<summary>
///
限定宽度
///
</summary>
public
int
LimitWidth
{
get
{
return
_limitwidth;
}
set
{
_limitwidth
=
value;
}
}
///
<summary>
///
限定高度
///
</summary>
public
int
LimitHeight
{
get
{
return
_limitheight;
}
set
{
_limitheight
=
value;
}
}
///
<summary>
///
缩略图宽度
///
</summary>
public
int
TWidth
{
get
{
return
_twidth;
}
set
{
_twidth
=
value;
}
}
///
<summary>
///
缩略图高度
///
</summary>
public
int
THeight
{
get
{
return
_theight;
}
set
{
_theight
=
value;
}
}
///
<summary>
///
文件大小
///
</summary>
public
int
Size
{
get
{
return
_size;
}
set
{
_size
=
value;
}
}
///
<summary>
///
是否成比例
///
</summary>
public
bool
IsRate
{
get
{
return
_israte;
}
set
{
_israte
=
value;
}
}
///
<summary>
///
是否生成缩略图
///
</summary>
public
bool
IsCreate
{
get
{
return
_israte;
}
set
{
_israte
=
value;
}
}
///
<summary>
///
存放图片的文件夹名称
///
</summary>
public
string
Path
{
get
{
return
_path;
}
set
{
_path
=
value;
}
}
///
<summary>
///
图片上传(默认:"等比压缩,限定上传尺寸2048*1536,缩略图尺寸100*100,限定上传大小1MB,存放在根目录UpdateImage中")
热心网友
时间:2022-04-23 07:30
放个隐藏文本,如果上传成功就把这个文本和按钮显示出来,同时把路径放到这个文本上,就获得路径了!