|
|
|
@ -2767,7 +2767,7 @@ namespace _24Hour.Controllers.Common
|
|
|
|
|
var hzname = $"{Path.GetExtension(fname)}"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (AllowedExtensions.Contains(hzname.ToLower())==false) |
|
|
|
|
if (AllowedExtensions.Contains(hzname.ToLower()) == false) |
|
|
|
|
{ |
|
|
|
|
outParm.IsSucceed = false; |
|
|
|
|
outParm.Message = "不被允许的文件格式!"; |
|
|
|
@ -2775,6 +2775,7 @@ namespace _24Hour.Controllers.Common
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var _path = Path.Combine("CaseFile", "card", DateTime.Now.ToString("yyyy-MM-dd")); |
|
|
|
|
var dic = Path.Combine(Environment.CurrentDirectory, "wwwroot", _path); |
|
|
|
|
|
|
|
|
@ -2786,16 +2787,14 @@ namespace _24Hour.Controllers.Common
|
|
|
|
|
var __path = Path.Combine(_path, filename); |
|
|
|
|
path = System.IO.Path.ChangeExtension(path, "aks"); |
|
|
|
|
|
|
|
|
|
using (var stream = new FileStream(path, FileMode.OpenOrCreate)) |
|
|
|
|
using (var ms = new MemoryStream()) |
|
|
|
|
{ |
|
|
|
|
await file.CopyToAsync(stream); |
|
|
|
|
await file.CopyToAsync(ms); |
|
|
|
|
var Encryptiondata = Elight.Utility.Encrypt.DataEncryption.Encryption(ms.ToArray()); |
|
|
|
|
await System.IO.File.WriteAllBytesAsync(path, Encryptiondata); |
|
|
|
|
} |
|
|
|
|
// var __path = $"{_path}/{filename}"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__path = System.IO.Path.ChangeExtension(__path, "aks"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var repath = "/" + __path.Replace(@"\", @"/"); |
|
|
|
|
outParm.IsSucceed = true; |
|
|
|
|
outParm.result = new |
|
|
|
@ -2828,7 +2827,7 @@ namespace _24Hour.Controllers.Common
|
|
|
|
|
var path = Path.Combine(Environment.CurrentDirectory, "wwwroot"+urlpath); |
|
|
|
|
if (System.IO.File.Exists(path)) |
|
|
|
|
{ |
|
|
|
|
var str = Convert.ToBase64String(System.IO.File.ReadAllBytes(path)); |
|
|
|
|
var str = Elight.Utility.Encrypt.DataEncryption.Decryptiones(path); |
|
|
|
|
result.result = new |
|
|
|
|
{ |
|
|
|
|
BaseStr = str |
|
|
|
@ -2856,7 +2855,7 @@ namespace _24Hour.Controllers.Common
|
|
|
|
|
var path = Path.Combine(Environment.CurrentDirectory, "wwwroot" + urlpath); |
|
|
|
|
if (System.IO.File.Exists(path)) |
|
|
|
|
{ |
|
|
|
|
return Convert.ToBase64String(System.IO.File.ReadAllBytes(path)); |
|
|
|
|
return Elight.Utility.Encrypt.DataEncryption.Decryptiones(path); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
@ -2898,74 +2897,7 @@ namespace _24Hour.Controllers.Common
|
|
|
|
|
|
|
|
|
|
public async Task<ActionResult> Upload_Files1(IFormFile file) |
|
|
|
|
{ |
|
|
|
|
Result outParm = new Result(); |
|
|
|
|
return await Task.Run(async () => |
|
|
|
|
{ |
|
|
|
|
if (file.Length <= 0) |
|
|
|
|
{ |
|
|
|
|
outParm.IsSucceed = false; |
|
|
|
|
outParm.Message = "请上传文件!"; |
|
|
|
|
return Json(outParm); |
|
|
|
|
} |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
var size = Request.Form.Files.Sum(f => f.Length); |
|
|
|
|
IFormFile file = Request.Form.Files.FirstOrDefault(); |
|
|
|
|
var fname = $@"{file.FileName}"; |
|
|
|
|
var hzname = $"{Path.GetExtension(fname)}"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (AllowedExtensions.Contains(hzname.ToLower())==false) |
|
|
|
|
{ |
|
|
|
|
outParm.IsSucceed = false; |
|
|
|
|
outParm.Message = "不被允许的文件格式!"; |
|
|
|
|
return Json(outParm); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var _path = Path.Combine("CaseFile", "card", DateTime.Now.ToString("yyyy-MM-dd")); |
|
|
|
|
var dic = Path.Combine(Environment.CurrentDirectory, "wwwroot", _path); |
|
|
|
|
|
|
|
|
|
if (!System.IO.Directory.Exists(dic)) |
|
|
|
|
Directory.CreateDirectory(dic); |
|
|
|
|
var filename = $"{DateTime.Now:yyyyMMddHHmmssfff}{Path.GetExtension(fname)}"; |
|
|
|
|
var filepath = Path.Combine(_path, $"{filename}"); |
|
|
|
|
var path = Path.Combine(dic, $"{filename}"); |
|
|
|
|
var __path = Path.Combine(_path, filename); |
|
|
|
|
path = System.IO.Path.ChangeExtension(path, "aks"); |
|
|
|
|
|
|
|
|
|
using (var stream = new FileStream(path, FileMode.OpenOrCreate)) |
|
|
|
|
{ |
|
|
|
|
await file.CopyToAsync(stream); |
|
|
|
|
} |
|
|
|
|
// var __path = $"{_path}/{filename}"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__path = System.IO.Path.ChangeExtension(__path, "aks"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var repath = "/" + __path.Replace(@"\", @"/"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
outParm.IsSucceed = true; |
|
|
|
|
outParm.result = new |
|
|
|
|
{ |
|
|
|
|
hzname = hzname, |
|
|
|
|
url = repath, |
|
|
|
|
tile = Path.GetFileNameWithoutExtension(file.FileName), |
|
|
|
|
size, |
|
|
|
|
DataPath = path, |
|
|
|
|
filePath = dic |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
catch (Exception e) |
|
|
|
|
{ |
|
|
|
|
outParm.IsSucceed = false; |
|
|
|
|
outParm.Message = $"文件上传失败!{e.Message}"; |
|
|
|
|
} |
|
|
|
|
return Json(outParm); |
|
|
|
|
}); |
|
|
|
|
return await Upload_Files(file); |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
} |
|
|
|
|