Exemplo n.º 1
0
        public ActionResult DataAdd(ww_Re modelRe, ww_Case modelCase, ww_Suspect modelSuspect, string Num, AnyModel model, List<HttpPostedFileBase> fileUpload)
        {
            int Resid=  BllBuilder.BuilRes().DataAdd(modelRe, Num, modelCase, modelSuspect);

            foreach (HttpPostedFileBase item in fileUpload)
            {

                if (item != null && Array.Exists(model.FilesToBeUploaded.Split(','), s => s.Equals(item.FileName)))
                {
                    // string path = AppDomain.CurrentDomain.BaseDirectory + "Picture/";
                    // string filename = Path.GetFileName(Request.Files[upload].FileName);
                    string dt = DateTime.Now.Millisecond.ToString();
                    item.SaveAs(Server.MapPath(Path.Combine("~/Picture/", dt + item.FileName)));
                    ww_Photo myPhoto = new ww_Photo()
                    {
                        BoolDel = false,
                        ResID = Resid,
                        PhotoURL = "/Picture/" + dt + item.FileName,
                    };
                    BllBuilder.BuilPhoto().Upload(myPhoto);
                    // item.SaveAs(Server.MapPath("~/Picture/NewFolder1"));
                    //Save or do your action -  Each Attachment ( HttpPostedFileBase item )
                }
            }

            //ViewBag.Resid = Resid;
            return RedirectToAction("Alert", "Login", new { alert = "录入成功!!!" });
        }
Exemplo n.º 2
0
        public ActionResult UploadAction(AnyModel model, List<HttpPostedFileBase> fileUpload, int ResId)
        {
            // Your Code - / Save Model Details to DB

            // Handling Attachments -
            foreach (HttpPostedFileBase item in fileUpload)
            {

                if (item != null && Array.Exists(model.FilesToBeUploaded.Split(','), s => s.Equals(item.FileName)))
                {
                   // string path = AppDomain.CurrentDomain.BaseDirectory + "Picture/";
                   // string filename = Path.GetFileName(Request.Files[upload].FileName);
                    string dt = DateTime.Now.Millisecond.ToString();
                    item.SaveAs(Server.MapPath(Path.Combine("~/Picture/", dt + item.FileName)));
                    ww_Photo myPhoto=new ww_Photo(){
                        BoolDel=false,
                        ResID = ResId,
                        PhotoURL = "/Picture/" + dt + item.FileName,
                        };
                    BllBuilder.BuilPhoto().Upload(myPhoto);
                    // item.SaveAs(Server.MapPath("~/Picture/NewFolder1"));
                    //Save or do your action -  Each Attachment ( HttpPostedFileBase item )
                }
            }
            //var file = Request.Files["fileUpload"];
            //file.SaveAs(Server.MapPath("~/Picture/NewFolder1"));
            return RedirectToAction("Alert", "Login", new { alert = "上传成功!!!" });
        }