C#文件上传头文件
来源:互联网 发布:小学生电脑绘画软件 编辑:程序博客网 时间:2024/05/16 15:54
//这边HttpPostedFile 因为我静态页上传的,你也可以改为FileUplaod
publicbool isImage(HttpPostedFile postfile)
{
string[] exten = { "255216", "7173", "13780" };
int contentLength = postfile.ContentLength;
byte[] imgArray =newbyte[contentLength];
postfile.InputStream.Read(imgArray, 0, contentLength);
MemoryStream ms =new MemoryStream(imgArray);
BinaryReader br =new BinaryReader(ms);
string filecess ="";
byte buffer;
try
{
buffer = br.ReadByte();
filecess = buffer.ToString();
buffer = br.ReadByte();
filecess += buffer.ToString();
}
catch { }
finally { br.Close(); ms.Dispose(); ms.Close(); }
foreach (string s in exten)
{
if (s == filecess)
returntrue;
}
returnfalse;
}
//这是一些文件头格式
publicenum FileExtension
{
JPG =255216,
GIF =7173,
PNG =13780,
SWF =6787,
RAR =8297,
ZIP =8075,
_7Z =55122
}
publicbool isImage(HttpPostedFile postfile)
{
string[] exten = { "255216", "7173", "13780" };
int contentLength = postfile.ContentLength;
byte[] imgArray =newbyte[contentLength];
postfile.InputStream.Read(imgArray, 0, contentLength);
MemoryStream ms =new MemoryStream(imgArray);
BinaryReader br =new BinaryReader(ms);
string filecess ="";
byte buffer;
try
{
buffer = br.ReadByte();
filecess = buffer.ToString();
buffer = br.ReadByte();
filecess += buffer.ToString();
}
catch { }
finally { br.Close(); ms.Dispose(); ms.Close(); }
foreach (string s in exten)
{
if (s == filecess)
returntrue;
}
returnfalse;
}
//这是一些文件头格式
publicenum FileExtension
{
JPG =255216,
GIF =7173,
PNG =13780,
SWF =6787,
RAR =8297,
ZIP =8075,
_7Z =55122
}
0 0
- C#文件上传头文件
- 文件上传 request 头信息
- C#文件上传
- C#文件上传类
- C#文件上传类
- 文件上传(C#代码)
- 文件上传(C#代码)
- c#做文件上传
- c#文件上传源代码
- C#文件上传类
- c#实现文件上传
- C#文件上传类
- C#文件上传
- C#文件上传功能
- C#上传文件
- C# 上传文件
- C# 上传文件
- C#上传文件
- 总结☺️
- android开发方向
- 读《疯狂Java讲义》笔记总结二
- Nginx虚拟主机的配置
- Ext.js5用XML数据做的表(12)
- C#文件上传头文件
- 从涂鸦到发布——理解API的设计过程
- easy ui datagrid 从编辑框中获取值
- 有关Jar的小经历
- Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xm
- Flex4 与 PHP 通讯
- SQL Server存储过程Return、output参数及使用技巧
- iOS 方法objc_msgSend()编译不通过
- LNK1123: 转换到 COFF 期间失败: 文件无效或损坏