コード例 #1
0
        public JsonResult AddSuper(Master_SuperCategory sc)
        {
            HttpPostedFileBase file = Request.Files[0]; //Uploaded file
            int    fileSize         = file.ContentLength;
            string fileName         = file.FileName;
            string filePath         = "/SuperImages/" + fileName;

            file.SaveAs(Server.MapPath(filePath));
            string mimeType = file.ContentType;

            System.IO.Stream fileContent = file.InputStream;
            //To save file, use SaveAs method
            //fname = Path.Combine(Server.MapPath("~/SuperImages/" + fileName));
            //file.SaveAs(fname); //File will be saved in application root
            //sc.SuperCategoryIcon = fname;
            sc.SuperCategoryIcon = filePath;
            return(Json(db.AddSuperC(sc), JsonRequestBehavior.AllowGet));
        }