private void UploadedFile(List <IFormFile> model, int vehicleID) { string uniqueFileName = null; string filePath = string.Empty; string tempFile = ""; if (model != null) { foreach (var images in model) { if (images.FileName == tempFile) { continue; } uniqueFileName = Guid.NewGuid().ToString() + "_" + images.FileName; filePath = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "Vehicle")).Root + $@"\{uniqueFileName}"; using (var fileStream = new FileStream(filePath, FileMode.Create)) { images.CopyTo(fileStream); } var image = new Image { VehicleId = vehicleID, path = filePath }; _vehicle.AddImages(image); //Add Path tempFile = images.FileName; } } }