|
|
@ -2771,6 +2771,43 @@ namespace _24Hour.Controllers.Common |
|
|
|
return BadRequest(); |
|
|
|
return BadRequest(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
|
|
/// 通用文件下载接口 |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
/// <param name="filename"></param> |
|
|
|
|
|
|
|
/// <returns></returns> |
|
|
|
|
|
|
|
[HttpGet] |
|
|
|
|
|
|
|
[Route("RequestDeleteFile")] |
|
|
|
|
|
|
|
public Result RequestDeleteFile(string filename) //[FromBody] dynamic Json |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (System.IO.File.Exists(filename)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
filename = filename.Replace(@"\\", @"\"); |
|
|
|
|
|
|
|
var data = System.IO.Path.Combine(Environment.CurrentDirectory, "wwwroot"); |
|
|
|
|
|
|
|
if (filename.Contains(data) == false) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return Result.Error("操作失败" + "不可删除"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var FileName = System.IO.Path.GetFileName(filename); |
|
|
|
|
|
|
|
var FilePath = filename; |
|
|
|
|
|
|
|
try |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
System.IO.File.Delete(filename); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch(Exception ex) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return Result.Error("操作失败"+ex.Message); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Result.Success("操作成功"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return Result.Error("操作失败" + "文件不存在"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
private readonly string[] AllowedExtensions = new string[] { ".png", ".jpg", ".jpeg", ".bmp", ".xlsx", ".aks" }; |
|
|
|
private readonly string[] AllowedExtensions = new string[] { ".png", ".jpg", ".jpeg", ".bmp", ".xlsx", ".aks" }; |
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// 文件上传--附件 |
|
|
|
/// 文件上传--附件 |
|
|
|