Skip to content

Commit

Permalink
仅支持上传图片文件。close: #78
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Sep 3, 2024
1 parent 6ca3c57 commit 1b6ddfe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions NewLife.Cube/Areas/Admin/Controllers/UserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,12 @@ public async Task<ActionResult> Info(User user)
var file = HttpContext.Request.Form.Files["avatar"];
if (file != null)
{
var ext = Path.GetExtension(file.FileName);
//if (ext.EqualIgnoreCase(".exe", ".bat", ".com", ".vbs", ".js", ".jar", ".msi", ".lnk"))
// throw new Exception("禁止上传可执行文件!");
if (!ext.EqualIgnoreCase(".png", ".jpg", ".gif", ".bmp", ".tiff", ".svg"))
throw new Exception("仅支持上传图片文件!");

//var set = CubeSetting.Current;
//var fileName = user.ID + Path.GetExtension(file.FileName);
var att = await SaveFile(user, file, null, null);
Expand Down
4 changes: 4 additions & 0 deletions NewLife.CubeNC/Areas/Admin/Controllers/UserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,10 @@ public async Task<ActionResult> Info(User user)
var file = HttpContext.Request.Form.Files["avatar"];
if (file != null)
{
var ext = Path.GetExtension(file.FileName);
if (!ext.EqualIgnoreCase(".png", ".jpg", ".gif", ".bmp", ".tiff", ".svg"))
throw new Exception("仅支持上传图片文件!");

//var set = CubeSetting.Current;
//var fileName = user.ID + Path.GetExtension(file.FileName);
var att = await SaveFile(user, file, null, null);
Expand Down

0 comments on commit 1b6ddfe

Please sign in to comment.