Example #1
0
        public JsonResult UploadImage()
        {
            string imgPath = string.Empty;
            long requestID;
            CustomerDAL customerDALObj = new CustomerDAL();

                for (int i = 0; i < Request.Files.Count; i++)
                {
                    HttpPostedFileBase file = Request.Files[i]; //Uploaded file
                    //Use the following properties to get file's name, size and MIMEType
                    int fileSize = file.ContentLength;
                    string fileName = file.FileName;
                    string mimeType = file.ContentType;
                    System.IO.Stream fileContent = file.InputStream;
                    requestID = customerDALObj.GetNextNewAccountRequestID();
                    //To save file, use SaveAs method
                    imgPath = "Images/NewAccountCreation/" + "NAC" + requestID + ".jpg";
                    file.SaveAs(Server.MapPath("~/") + imgPath); //File will be saved in directory
                }
                return Json("Image uploaded successfully !");
        }