예제 #1
0
        public ActionResult Create(Music1 music1)
        {
            HttpPostedFileBase file  = Request.Files["music"];
            HttpPostedFileBase file2 = Request.Files["image"];

            if (music1 != null)
            {
                if (file != null)
                {
                    string filePath     = file.FileName;
                    string fileName     = filePath.Substring(filePath.LastIndexOf("\\") + 1);
                    string serverpath   = Server.MapPath(@"\Music\") + fileName;
                    string relativepath = @"/Music/" + fileName;
                    file.SaveAs(serverpath);
                    music1.music_music = relativepath;
                }
                if (file2 != null)
                {
                    string filePath     = file2.FileName;
                    string fileName     = filePath.Substring(filePath.LastIndexOf("\\") + 1);
                    string serverpath   = Server.MapPath(@"\image\music\") + fileName;
                    string relativepath = @"/image/music/" + fileName;
                    file2.SaveAs(serverpath);
                    music1.music_image = relativepath;
                }
                music1.type_id    = 1;
                music1.mana_id    = Convert.ToInt32(Session["mana_id"].ToString());
                music1.music_time = DateTime.Now;
                mb.Add(music1);
                return(Content("<script>alert('创建成功!');window.open('" + Url.Action("List", "Music") + "','_self');</script>"));
            }
            return(View(music1));
        }
예제 #2
0
 // POST: api/music
 public int Post([FromBody] MusicModel m)
 {
     return(bll.Add(m));
 }