Example #1
0
        public ActionResult UploadImage()
        {
            Response           _resp         = new Response();
            string             strresult     = "";
            String             callback      = System.Web.HttpContext.Current.Request.QueryString["CKEditorFuncNum"].ToString();
            UploadConfig       _uploadConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~").GetSection("UploadConfig") as Bx_Core.Config.UploadConfig;
            HttpFileCollection files         = System.Web.HttpContext.Current.Request.Files;

            for (int iFile = 0; iFile < files.Count; iFile++)
            {
                HttpPostedFile postedFile = files[iFile];
                _resp = _productmanager.UploadImg(_uploadConfig, postedFile, "image");
                if (_resp.Status == 0)
                {
                    strresult += "<script>alert(' " + _resp.Message + " ')</script>";
                }
                else
                {
                    _resp.Data = "http://" + System.Web.HttpContext.Current.Request.Url.Host.ToString() + ":" + System.Web.HttpContext.Current.Request.Url.Port.ToString() + _resp.Data;
                    strresult += "<script type=\"text/javascript\">";
                    strresult += "window.parent.CKEDITOR.tools.callFunction(" + callback + ",'" + _resp.Data + "','')";
                    strresult += ("</script>");
                }
            }

            return(Content(strresult));
        }