Exemple #1
0
        public ActionResult Files(IEnumerable <HttpPostedFileBase> files)
        {
            // TODO:
            foreach (var file in files)
            {
                using (var stream = file.InputStream)
                {
                    using (var destination = new MemoryStream())
                    {
                        stream.CopyTo(destination);
                        var bytes = destination.ToArray();

                        var model = new PhotoModel
                        {
                            Name = file.FileName,
                            Data = Convert.ToBase64String(bytes),
                            Id   = Guid.NewGuid()
                        };

                        _adminData.SavePhoto(model);
                    }
                }
            }

            return(Json("All files have been successfully stored."));
        }