新增加文件上传

This commit is contained in:
不做码农
2021-12-09 22:21:44 +08:00
parent 6f11bae15c
commit 944967afa3
6 changed files with 214 additions and 6 deletions

View File

@@ -82,7 +82,7 @@ namespace ZR.Admin.WebApi.Controllers
[ActionPermissionFilter(Permission = "system")]
public IActionResult UploadFile([FromForm(Name = "file")] IFormFile formFile)
{
if (formFile == null) throw new CustomException(ResultCode.PARAM_ERROR, "上传图片不能为空");
if (formFile == null) throw new CustomException(ResultCode.PARAM_ERROR, "上传文件不能为空");
string fileExt = Path.GetExtension(formFile.FileName);
string fileName = FileUtil.HashFileName(Guid.NewGuid().ToString()).ToLower() + fileExt;
string finalFilePath = Path.Combine(WebHostEnvironment.WebRootPath, FileUtil.GetdirPath("uploads"), fileName);

View File

@@ -251,9 +251,8 @@ $if(genTable.SortField != "" && genTable.SortField != null)
$end
$if(replaceDto.UploadFile == 1)
//图片上传成功方法
handleUploadSuccess(res, columnName) {
this.form[columnName] = res.data;
console.log(JSON.stringify(this.form), JSON.stringify(res))
handleUploadSuccess(columnName, filelist) {
this.form[columnName] = filelist;
},
$end
$foreach(item in genTable.Columns)