Click here to Skip to main content
14,884,084 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to assign image file to IFormFile Variable?
C#
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

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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900