Click here to Skip to main content
14,544,533 members
Rate this:
Please Sign up or sign in to vote.
See more: , +
How to assign image file to IFormFile Variable?
using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;

namespace IFrameTesting.ViewModels
{
    public class ImageModelViewModels
    {
        [Display(Name ="Photo")]
        public IFormFile Photo { get; set; }
        public byte[] ImageData { get; set; }


        [Display(Name = "Converted Photo")]
        public IFormFile ConvertedIFormFilePhoto { get; set; }
    }
}
Suppose there is image inside solution Explore path is wwwroot/images/abc.jpg , I want to assign this abc.jpg to variable ConvertedIFormFilePhoto how to achieve it?

What I have tried:

I have successfully converted and store to server side image. I want to get that image from server side and assign to variable ConvertedIFormFilePhoto how to achieve that?
Posted
Updated 22-May-20 4:31am
v2

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

You can't. IFormFile represents an image uploaded by the user, not an image that's already stored on your server.

Upload files in ASP.NET Core | Microsoft Docs[^]
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100