Пример #1
0
        public ActionResult UploadPicture(HttpPostedFileBase filedata)
        {
            xheditorModel model = new xheditorModel();

            try
            {
                if (filedata.ContentLength > 0)
                {
                    var fileName = Guid.NewGuid().ToString();
                    var file     = BtVideo.Helpers.Utilities.UploadImageFile(filedata.InputStream, "/Content/Pictures/Blog", fileName, 800, 400, BtVideo.Helpers.ImageSaveType.Original);

                    model.msg = "/Content/Pictures/Blog/" + file;
                }

                JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
                return(this.Content(javaScriptSerializer.Serialize(model)));
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                filedata = null;
            }
        }
Пример #2
0
        public ActionResult UploadVideo(HttpPostedFileBase filedata)
        {
            xheditorModel model = new xheditorModel();

            if (filedata.ContentLength > 0)
            {
                var guid     = Guid.NewGuid();
                var fileN    = filedata.FileName.Split('.').LastOrDefault();
                var fileName = guid + "." + fileN;

                //Activity.Helpers.IO.UploadImageFile(filedata.InputStream, "/Content/videos", fileName, 720);

                string url = System.Web.HttpContext.Current.Server.MapPath("/content/videos/" + fileName);

                string directory = Path.GetDirectoryName(url);
                if (directory != null && !Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }

                filedata.SaveAs(url);

                filedata = null;

                model.msg = "/Content/videos/" + fileName;
            }

            JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();

            return(this.Content(javaScriptSerializer.Serialize(model)));
        }
Пример #3
0
        public ActionResult UploadPicture(HttpPostedFileBase filedata)
        {
            xheditorModel model = new xheditorModel();

            if (filedata.ContentLength > 0)
            {
                var fileName = filedata.FileName;
                IO.UploadImageFile(filedata.InputStream, "/Content/Pictures/Blog", fileName, 720);

                model.msg = "/Content/Pictures/Blog/" + fileName;
            }

            JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();

            return(this.Content(javaScriptSerializer.Serialize(model)));
        }
Пример #4
0
        public ActionResult UploadPicture(HttpPostedFileBase filedata)
        {
            xheditorModel model = new xheditorModel();

            if (filedata.ContentLength > 0)
            {
                var guid     = Guid.NewGuid();
                var fileName = guid + ".jpg";
                Hope.Helpers.IO.UploadImageFile(filedata.InputStream, "/Content/images", fileName, 720);

                model.msg = "/Content/images/" + fileName;
            }

            JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();

            return(this.Content(javaScriptSerializer.Serialize(model)));
        }