1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.AspNetCore.Http;
- using Microsoft.Extensions.Logging;
- using Microsoft.Extensions.Options;
- using System.DrawingCore.Imaging;
- using System.IO;
- using Library;
- using System.Collections;
- using LitJson;
- using System.Globalization;
- using System.Web;
- // For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
- namespace MySystem.Areas.Api.Controllers
- {
- [Area("Api")]
- [Route("Api/[controller]/[action]")]
- public class PublicMethodController : BaseController
- {
- public PublicMethodController(IHttpContextAccessor accessor) : base(accessor)
- {
- }
- #region 系统-上传图片
- public JsonResult UploadPhotoByBase64(string value)
- {
- try
- {
- value = value.Replace("data:image/png;base64,", "");
- string base64str = HttpUtility.UrlDecode(value).Replace(" ", "+");
- string dummyData = base64str.Replace("%", "").Replace(",", "").Replace(" ", "+");
- if (dummyData.Length % 4 > 0)
- {
- dummyData = dummyData.PadRight(dummyData.Length + 4 - dummyData.Length % 4, '=');
- }
- string Icon = function.base64StringToImage(dummyData, "/static/upload/" + DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + "/", "MT" + function.MD5_16(Guid.NewGuid().ToString()) + ".png");
- return Json(new AppResultJson() { Status = "1", Info = "", Data = Icon });
- }
- catch (Exception ex)
- {
- LogHelper.Instance.WriteLog(DateTime.Now + ":" + ex.ToString(), "系统上传图片异常");
- return Json(new AppResultJson() { Status = "1", Info = "", Data = "" });
- }
- }
- #endregion
- }
- }
|