1
Answer

Upload image on folder and path stored in DB in core api

selvi jp

selvi jp

3y
581
1

Here i can upload image but I want to upload image without webHostEnvironment.WebRootPath in CORE API

private string UpdateUploadedFile(profileImg model)
        {
            string uniqueFileName = null;

            if (model.profile_imagePath != null)
            {

                string uploadsFolder = Path.Combine(webHostEnvironment.WebRootPath, "images");

                uniqueFileName = "profile" + "_" + model.profile_imagePath.FileName;

                string filePath = Path.Combine(uploadsFolder, uniqueFileName);
                using (var fileStream = new FileStream(filePath, FileMode.Create))
                {
                    model.profile_imagePath.CopyTo(fileStream);
                }
            }
            return uniqueFileName;
        }

Answers (1)