/// <summary>
/// 根据FileUpload控件名获取上传文件(大小)类型
/// </summary>
/// <param name="upload">FileUpload控件名</param>
/// <returns>上传文件(大小)类型</returns>
public string GetByteUnit(HtmlInputFile upload)
{
string byteUnit = null;
if (upload.PostedFile.ContentLength < 1024)//上传文件小于1K
{
byteUnit = upload.PostedFile.ContentLength + "BYTE";
}
else if (upload.PostedFile.ContentLength >= 1024 && upload.PostedFile.ContentLength < 1048576)//上传文件大于等于1K小于1M
{
byteUnit = upload.PostedFile.ContentLength / 1024 + "KB";
}
else if (upload.PostedFile.ContentLength >= 1048576 && upload.PostedFile.ContentLength < 2097152)//上传文件大于1M小于2MB
{
byteUnit = upload.PostedFile.ContentLength / 1024 / 1024 + "MB";
}
else
{
byteUnit = null;
}
return byteUnit;
}
根据FileUpload控件名获取上传文件(大小)类型
最新推荐文章于 2021-01-13 17:06:45 发布
该方法根据HtmlInputFile类型的FileUpload控件名称,计算并返回上传文件的大小单位,包括BYTE, KB, MB。如果文件大小超过2MB,则返回null。"
102750798,8283525,编程语言类型详解:强类型、弱类型、动态与静态类型的区别,"['编程语言', '类型系统', '强类型语言', '弱类型语言', '动态类型语言', '静态类型语言']
摘要由CSDN通过智能技术生成