|
|
@ -2739,6 +2739,8 @@ namespace _24Hour.Controllers.Common |
|
|
|
#endregion |
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
#region 文件上传 |
|
|
|
#region 文件上传 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private string[] AllowedExtensions = new string[] { ".png", ".jpg", ".jpeg", ".bmp", ".zip" ,".xls",".xlsx"}; |
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// 文件上传--附件 |
|
|
|
/// 文件上传--附件 |
|
|
|
/// <param name="file"></param> |
|
|
|
/// <param name="file"></param> |
|
|
@ -2764,8 +2766,8 @@ namespace _24Hour.Controllers.Common |
|
|
|
var fname = $@"{file.FileName}"; |
|
|
|
var fname = $@"{file.FileName}"; |
|
|
|
var hzname = $"{Path.GetExtension(fname)}"; |
|
|
|
var hzname = $"{Path.GetExtension(fname)}"; |
|
|
|
|
|
|
|
|
|
|
|
var allowedExtensions = new string[] { ".png", ".jpg", ".jpeg", ".bmp", ".zip" }; |
|
|
|
|
|
|
|
if (allowedExtensions.Contains(hzname.ToLower())==false) |
|
|
|
if (AllowedExtensions.Contains(hzname.ToLower())==false) |
|
|
|
{ |
|
|
|
{ |
|
|
|
outParm.IsSucceed = false; |
|
|
|
outParm.IsSucceed = false; |
|
|
|
outParm.Message = "不被允许的文件格式!"; |
|
|
|
outParm.Message = "不被允许的文件格式!"; |
|
|
@ -2814,10 +2816,13 @@ namespace _24Hour.Controllers.Common |
|
|
|
return Json(outParm); |
|
|
|
return Json(outParm); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[HttpGet] |
|
|
|
[HttpGet] |
|
|
|
[Route("GetImageFile")] |
|
|
|
[Route("GetImageFile")] |
|
|
|
public async Task<Result> GetImageFile(string file) |
|
|
|
public async Task<Result> GetImageFile(string file) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
Result result = new Result(); |
|
|
|
Result result = new Result(); |
|
|
|
var urlpath = file.Replace("/", @"\"); |
|
|
|
var urlpath = file.Replace("/", @"\"); |
|
|
|
var path = Path.Combine(Environment.CurrentDirectory, "wwwroot"+urlpath); |
|
|
|
var path = Path.Combine(Environment.CurrentDirectory, "wwwroot"+urlpath); |
|
|
@ -2838,6 +2843,43 @@ namespace _24Hour.Controllers.Common |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public class GetBaseStringDto |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
public List<string> Files { get; set; } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost] |
|
|
|
|
|
|
|
[Route("GetImageFiles")] |
|
|
|
|
|
|
|
public async Task<Result> GetImageFiles(GetBaseStringDto file) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
//根据输入url获取base64值 |
|
|
|
|
|
|
|
var getstr = (string s) => |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var urlpath = s.Replace("/", @"\"); |
|
|
|
|
|
|
|
var path = Path.Combine(Environment.CurrentDirectory, "wwwroot" + urlpath); |
|
|
|
|
|
|
|
if (System.IO.File.Exists(path)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return Convert.ToBase64String(System.IO.File.ReadAllBytes(path)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return ""; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
//根据输入url获取文件是否存在 |
|
|
|
|
|
|
|
var getexist = (string s) => |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var urlpath = s.Replace("/", @"\"); |
|
|
|
|
|
|
|
var path = Path.Combine(Environment.CurrentDirectory, "wwwroot" + urlpath); |
|
|
|
|
|
|
|
return System.IO.File.Exists(s); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
var data = file.Files.Select(x => new |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
IsExist = getexist(x), |
|
|
|
|
|
|
|
BaseStr = getstr(x) |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
result.result = data; |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// 文件上传--附件 |
|
|
|
/// 文件上传--附件 |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
@ -2865,8 +2907,8 @@ namespace _24Hour.Controllers.Common |
|
|
|
var fname = $@"{file.FileName}"; |
|
|
|
var fname = $@"{file.FileName}"; |
|
|
|
var hzname = $"{Path.GetExtension(fname)}"; |
|
|
|
var hzname = $"{Path.GetExtension(fname)}"; |
|
|
|
|
|
|
|
|
|
|
|
var allowedExtensions = new string[] { ".png", ".jpg", ".jpeg", ".bmp",".zip" }; |
|
|
|
|
|
|
|
if (allowedExtensions.Contains(hzname.ToLower())==false) |
|
|
|
if (AllowedExtensions.Contains(hzname.ToLower())==false) |
|
|
|
{ |
|
|
|
{ |
|
|
|
outParm.IsSucceed = false; |
|
|
|
outParm.IsSucceed = false; |
|
|
|
outParm.Message = "不被允许的文件格式!"; |
|
|
|
outParm.Message = "不被允许的文件格式!"; |
|
|
|