60 lines
1.7 KiB
C#
60 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Web;
|
|
|
|
namespace VRS.Handler
|
|
{
|
|
/// <summary>
|
|
/// UploadFile 的摘要说明
|
|
/// </summary>
|
|
public class UploadFile : IHttpHandler
|
|
{
|
|
|
|
public void ProcessRequest(HttpContext context)
|
|
{
|
|
context.Response.ContentType = "text/plain";
|
|
|
|
int code = 0;
|
|
string msg = "上传失败";
|
|
string url = "";
|
|
string qrstr = "";
|
|
if (context.Request.Files.Count > 0)
|
|
{
|
|
var file = context.Request.Files[0];
|
|
string fileName = Guid.NewGuid().ToString() + file.FileName.Substring(file.FileName.LastIndexOf("."));
|
|
string savePath = "Upload/";
|
|
if (!Directory.Exists("~/" + savePath))
|
|
Directory.CreateDirectory(context.Server.MapPath("~/" + savePath));
|
|
|
|
savePath += fileName;
|
|
string serverPath = context.Server.MapPath("~/" + savePath);
|
|
file.SaveAs(serverPath);
|
|
|
|
qrstr = Util.QRCodeHelper.CodeDecoder(serverPath);
|
|
if (qrstr.Contains("healthAct") && qrstr.Contains("qrCode"))
|
|
{
|
|
code = 1;
|
|
msg = "验证成功";
|
|
url = savePath;
|
|
}
|
|
else
|
|
{
|
|
|
|
msg = "验证失败";
|
|
}
|
|
}
|
|
|
|
context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(new { code = code, msg = msg, url = url, qrstr = qrstr }));
|
|
}
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
} |