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.

Developer technologies ASP.NET ASP.NET Core
Developer technologies C#
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. P a u l 10,761 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...


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.