3
Answers

upload image on folder with compressed size web api

selvi jp

selvi jp

3y
450
1
upload image on folder with compressed size web api.
 
 string sPath = "";
            sPath = HostingEnvironment.MapPath("~/Images/");
            WebApiDatabaseEntities entities = new WebApiDatabaseEntities();
            System.Web.HttpFileCollection hfc = System.Web.HttpContext.Current.Request.Files;
         
            // CHECK THE FILE COUNT.
            for (int iCnt = 0; iCnt <= hfc.Count - 1; iCnt++)
            {
                System.Web.HttpPostedFile hpf = hfc[iCnt];
               
                    if (hpf.ContentLength > 0)
                {
                  

                    // SAVE THE FILES IN THE FOLDER.   
                    var fileName = Path.GetFileName(hpf.FileName);
                    var random = Guid.NewGuid() + fileName;
                    hpf.SaveAs(sPath + Path.GetFileName(random));
                        iUploadedCnt = iUploadedCnt + 1; here i am storing image in folder
Answers (3)