Esempio n. 1
0
        public ActionResult InsertFileswithpath(IEnumerable <HttpPostedFileBase> Image)
        {
            bool   isExsit            = true;
            string res                = "";
            string attachmentName     = null;
            string stringImage        = null;
            List <TrnHdrDocModel> lst = new List <TrnHdrDocModel>();

            foreach (string upload in Request.Files)
            {
                string path = WebConfigurationManager.AppSettings[@"serverPath"];
                isExsit = Directory.Exists(path);
                string         filename    = Path.GetFileName(Request.Files[upload].FileName);
                TrnHdrDocModel obj         = new TrnHdrDocModel();
                string         strFilePath = path + filename;
                obj.FileNm   = filename;
                obj.FilePath = path;
                lst.Add(obj);
                if (isExsit)
                {
                    Request.Files[upload].SaveAs(Path.Combine(path, filename));
                }
            }
            return(Json(lst, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public ActionResult InsertFileswithpath(IEnumerable <HttpPostedFileBase> Image)
        {
            bool   isExsit            = true;
            string res                = "";
            string attachmentName     = null;
            string stringImage        = null;
            List <TrnHdrDocModel> lst = new List <TrnHdrDocModel>();

            foreach (string upload in Request.Files)
            {
                //isExsit = Directory.Exists(@"\\DOTNETSERVER\wwwroot\DevBL10\Images\");
                string path = WebConfigurationManager.AppSettings["serverPath"];

                isExsit = Directory.Exists(path);
                //isExsit = true;
                string filename = Path.GetFileName(Request.Files[upload].FileName);
                //string ServerPath = @"E:\computer\"; //@"\\DOTNETSERVER\wwwroot\DevBL10\Images\"; //\\DOTNETSERVER\wwwroot\DevBL10\Images

                // string fileName = tt.PostedFile.FileName;
                //string savePath = Server.MapPath(@"\\DOTNETSERVER\wwwroot\DevBL10\Images\" + filename);
                //tt.PostedFile.SaveAs(savePath);

                TrnHdrDocModel obj = new TrnHdrDocModel();

                string strFilePath = path + filename;
                obj.FileNm   = filename;
                obj.FilePath = path;
                //string strFilePath = ServerPath + filename;
                //DateTime fileCreatedDate = System.IO.File.GetCreationTime(strFilePath);
                lst.Add(obj);

                //foreach (var file in Image)
                //{
                //    var newimage = file.InputStream;

                //    using (var stream = new MemoryStream())
                //    {
                //        //newimage.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
                //        byte[] binData = stream.ToArray();
                //        stringImage = System.Convert.ToBase64String(binData);

                //    }
                //}


                //if (System.IO.File.Exists(strFilePath))
                //{
                //    //return Json(lst, JsonRequestBehavior.AllowGet);
                //}
                //else
                //{

                if (isExsit)
                {
                    Request.Files[upload].SaveAs(Path.Combine(path, filename));
                    //res = strFilePath;
                }
                //}
            }

            // return result;
            return(Json(lst, JsonRequestBehavior.AllowGet));
        }