Master.CanYinWu.Utility/WebHelper.cs

(开头部分) 10KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。


using System;
using System.IO;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Text.RegularExpressions;
namespace Master.CanYinWu.Utility
{
    public class WebHelper
    {
        /// <summary>
        /// 当前网站域名
        /// </summary>
        public static readonly string localHost = ConfigurationManager.AppSettings["LocalHost"];
        /// <summary>
        /// 图片域名
        /// </summary>
        public static readonly string ImgHost = ConfigurationManager.AppSettings["ImgHost"];
        /// <summary>
        /// PC端网站域名
        /// </summary>
        public static readonly string pcHost = ConfigurationManager.AppSettings["PcHost"];
        public static readonly string mipHost = ConfigurationManager.AppSettings["MipHost"];

        #region 公共的图片上传方法
        /// <summary>
        /// 公共的图片上传方法
        /// </summary>
        /// <param name="file"></param>
        /// <param name="msg"></param>
        ///  /// <param name="filePath">存放的文件路径</param>
        /// <returns></returns>
        ///  HttpPostedFileBase
        public static object CommonUploadImg(HttpPostedFileBase file, string filePath)
        {
            string[] imgType = { ".jpg", ".png", ".jpeg", ".bmp", "gif" };
            string fullDir = null;
            if (file == null || string.IsNullOrEmpty(file.FileName) || file.ContentLength == 0)
            {
                var msgdata = new { code = 500, msg = "请选择要上传的图片?" };

                return msgdata.ToJson();
            }
            string fileExt = Path.GetExtension(file.FileName);//得到文件的后缀名
            if (imgType.Contains(fileExt))
            {
                if (file.ContentLength > 1024 * 1024 * 3)
                {

                    return new { code = 500, msg = "上传图片不能超过3M" }.ToJson();
                }
                //拿到文件MD5值+文件扩展名
                string fileName = GetStreamMd5(file.InputStream) + fileExt;
                if (IsCreateFolder(filePath))
                {
                    //转换为相对路径             
                    fullDir = System.Web.HttpContext.Current.Server.MapPath(filePath + fileName);
                    file.SaveAs(fullDir);
                }
后面还有 235 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。