Example #1
0
        /// <summary>
        /// 上传
        /// </summary>
        /// <returns></returns>
        public ActionResult Upload()
        {
            string operation = WebHelper.GetQueryString("operation");

            if (operation == "ueconfig")
            {
                StringBuilder imageAllowFiles = new StringBuilder("[");
                foreach (string imgType in StringHelper.SplitString(shopConfigInfo.UploadImgType))
                {
                    imageAllowFiles.AppendFormat("\"{0}\",", imgType);
                }
                if (imageAllowFiles.Length > 1)
                {
                    imageAllowFiles.Remove(imageAllowFiles.Length - 1, 1);
                }
                imageAllowFiles.Append("]");

                string imageUrlPrefix = string.IsNullOrEmpty(shopConfigInfo.UploadServer) ? "/" : shopConfigInfo.UploadServer;

                return(Content(string.Format("{0}\"imageActionName\": \"uploadimage\", \"imageFieldName\": \"upfile\", \"imageMaxSize\": {1},\"imageAllowFiles\": {2}, \"imageCompressEnable\": true, \"imageCompressBorder\": 1600, \"imageInsertAlign\": \"none\", \"imageUrlPrefix\": \"{3}\", \"imagePathFormat\": \"\", \"imageManagerActionName\": \"listimage\",\"imageManagerListPath\": \"upload/image\",\"imageManagerListSize\": 20, \"imageManagerUrlPrefix\": \"/ueditor/net/\",\"imageManagerInsertAlign\": \"none\", \"imageManagerAllowFiles\": [\".png\", \".jpg\", \".jpeg\", \".gif\", \".bmp\"]{4}", "{", shopConfigInfo.UploadImgSize, imageAllowFiles, imageUrlPrefix, "}")));
            }
            if (operation == "uploadproductimage")//上传商品图片
            {
                HttpPostedFileBase file   = Request.Files[0];
                string             result = ShopUtils.SaveUplaodProductImage(file);
                return(Content(result));
            }
            if (operation == "uploadproducteditorimage")//上传商品编辑器中图片
            {
                HttpPostedFileBase file   = Request.Files[0];
                string             result = ShopUtils.SaveProductEditorImage(file);
                return(Content(string.Format("{2}'url':'upload/product/editor/{0}','state':'{1}'{3}", result, GetUEState(result), "{", "}")));
            }
            if (operation == "uploadadvertbody")//上传广告主体
            {
                HttpPostedFileBase file   = Request.Files[0];
                string             result = ShopUtils.SaveUploadAdvertBody(file);
                return(Content(result));
            }
            if (operation == "uploadbannerimg")//上传banner图片
            {
                HttpPostedFileBase file   = Request.Files[0];
                string             result = ShopUtils.SaveUploadBannerImg(file);
                return(Content(result));
            }
            if (operation == "uploadnewseditorimage")//上传新闻编辑器中的图片
            {
                HttpPostedFileBase file   = Request.Files[0];
                string             result = ShopUtils.SaveNewsEditorImage(file);
                return(Content(string.Format("{2}'url':'upload/news/{0}','state':'{1}'{3}", result, GetUEState(result), "{", "}")));
            }
            if (operation == "uploadbrandlogo")//上传品牌logo
            {
                HttpPostedFileBase file   = Request.Files[0];
                string             result = ShopUtils.SaveUploadBrandLogo(file);
                return(Content(result));
            }
            if (operation == "uploadhelpeditorimage")//上传帮助编辑器中的图片
            {
                HttpPostedFileBase file   = Request.Files[0];
                string             result = ShopUtils.SaveHelpEditorImage(file);
                return(Content(string.Format("{2}'url':'upload/help/{0}','state':'{1}'{3}", result, GetUEState(result), "{", "}")));
            }
            if (operation == "uploadfriendlinklogo")//上传友情链接logo
            {
                HttpPostedFileBase file   = Request.Files[0];
                string             result = ShopUtils.SaveUploadFriendLinkLogo(file);
                return(Content(result));
            }
            if (operation == "uploaduserrankavatar")//上传用户等级头像
            {
                HttpPostedFileBase file   = Request.Files[0];
                string             result = ShopUtils.SaveUploadUserRankAvatar(file);
                return(Content(result));
            }
            return(HttpNotFound());
        }