コード例 #1
0
ファイル: LS.cs プロジェクト: kcyung/FalaBricks
        // Adds an image to the database
        public bool AddImage(int postID, string imagePath)
        {
            PostManager Manager = new PostManager();
            bool        Success = Manager.AddImage(postID, imagePath);

            return(Success);
        }
コード例 #2
0
        public void UploadImage()
        {
            var httpRequest = HttpContext.Current.Request;

            if (httpRequest.Files.Count == 0)
            {
                throw new ValidationException("Odaberite fajl!");
            }
            if (string.IsNullOrEmpty(httpRequest.Form.Get("id")))
            {
                throw new ValidationException("Id posta je obavezan parametar!");
            }

            int postId = int.Parse(httpRequest.Form.Get("id"));

            HttpPostedFile postedFile = httpRequest.Files[0];
            string         rootFolder = HttpContext.Current.Server.MapPath($"~/Content/Posts/" + postId);
            string         extension  = Path.GetExtension(postedFile.FileName);

            PostManager.AddImage(rootFolder, postedFile.InputStream, postedFile.FileName, postId);
        }