Example #1
0
 public async Task <IActionResult> ImageUpload(IFormFile image)
 {
     if (image != null && image.Length > 0)
     {
         var file = image;
         //There is an error here
         if (file.Length > 0)
         {
             var fileName = $"{BlogPost.MakeFriendly(Path.GetFileNameWithoutExtension(file.FileName))}.{Path.GetExtension(file.FileName)}";
             using (var fileStream = new FileStream(Path.Combine(uploadsPath, fileName), FileMode.Create))
             {
                 await file.CopyToAsync(fileStream);
             }
         }
     }
     return(View("Edit"));
 }