示例#1
0
        public ActionResult DoUpload(FormCollection form)
        {
            EnablePageLayout(false);
            var model = new MediaUploadFrameViewModel();

            ComLib.MapperSupport.MapperWebForms.UpdateModel(model, form, "MediaUploadFrameModel", _excludeMediaUploadFrameProps);
            int refGroup = model.IsFolderMode ? 0 : ComLib.Web.Lib.Core.ModuleMap.Instance.GetId(model.ModelName);
            BoolMessageItem <IList <MediaFile> > result = model.IsFolderMode
                         ? MediaHelper.CreateMediaFiles(Request, ModelState, model.RefId, 0, true)
                         : MediaHelper.CreateMediaFiles(Request, ModelState, model.RefId, refGroup, false);

            model.IsUploadMode          = !result.Success;
            model.RunJavascriptCallBack = result.Success;
            if (result.Success)
            {
                FlashMessages("File(s) have been successfully uploaded.");
            }
            else if (result.Item != null && result.Item.Count > 0)
            {
                foreach (var file in result.Item)
                {
                    FlashErrors(file.Errors);
                }
            }

            return(View("Upload", model));
        }
示例#2
0
        public ActionResult Upload(bool isFolderMode, int refId, string modelName,
                                   int numberOfUploadsAllowed = 4, bool showDetailUI = true, int width = 300, int height = 200, string jscallback = "")
        {
            MediaUploadFrameViewModel options = new MediaUploadFrameViewModel
            {
                IsFolderMode           = isFolderMode,
                RefId                  = refId,
                ModelName              = modelName,
                NumberOfUploadsAllowed = numberOfUploadsAllowed,
                ShowDetailUI           = showDetailUI,
                Width                  = width,
                Height                 = height,
                IsUploadMode           = true,
                JavascriptCallback     = jscallback,
                RunJavascriptCallBack  = false
            };

            EnablePageLayout(false);
            return(View(options));
        }