SourceCode/RFrameGenerate.Common/UpLoadFileHelp.cs
(开头部分) 5KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;
namespace RFrameGenerate.Common
{
public static class UpLoadFileHelp
{
/// <summary>
/// 上传的路径
/// </summary>
public static string UpLoadFilePathDir { get; set; }
public static bool HasFile(this HttpPostedFileBase file)
{
return (file != null && file.ContentLength > 0) ? true : false;
}
/// <summary>
/// 验证文件类型
/// </summary>
/// <param name="file">上传上来的文件</param>
/// <returns></returns>
public static Boolean IsAllowedExtension(this HttpPostedFileBase file)
{
int fileLen = file.ContentLength;
byte[] imgArray = new byte[fileLen];
file.InputStream.Read(imgArray, 0, fileLen);
MemoryStream ms = new MemoryStream(imgArray);
System.IO.BinaryReader br = new System.IO.BinaryReader(ms);
string fileclass = "";
byte buffer;
try
{
buffer = br.ReadByte();
fileclass = buffer.ToString();
buffer = br.ReadByte();
fileclass += buffer.ToString();
}
catch
{
}
finally
{
br.Close();
ms.Close();
}
//说明255216是jpg;7173是gif;6677是BMP,13780是PNG;7790是exe,8297是rar
if (fileclass == "255216" || fileclass == "7173" || fileclass == "6677" || fileclass == "13780")
return true;
else
return false;
}
/// <summary>
/// 将文件保存文件夹
后面还有 100 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。