asp.net core 5 how to get .gif from input file using XmlHttpRequest()

Cycler 21 Reputation points
2021-10-16T21:02:39.147+00:00

Hi, guys!
Could anyone help me with this issue? I am still having trouble when IFormFile is always null. Thank you.

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,148 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,218 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. P a u l 10,406 Reputation points
    2021-10-16T23:15:02.963+00:00

    It seems to work for me - this is from my view:
    https://pastebin.com/raw/t2gqs0PR

    (had to use PB because including it here caused the request to be blocked)

    Here's from the HomeController:

       [HttpPost]  
       public IActionResult Upload(IFormFile file) {          
           return Content("done");  
       }  
    

    Here's a breakpoint in that method:

    141038-image.png

    This is a fresh sample ASP.NET Core MVC project - is this roughly what your code looks like?

    1 person found this answer helpful.
    0 comments No comments

  2. Cycler 21 Reputation points
    2021-10-17T16:09:35.277+00:00

    Thank you. But now my file uploads locally but nothing performs on hosting...