JavaScript File Upload to C# Web API

preview_player
Показать описание
This project demonstrates how to use the JavaScript Drag & Drop events. We create an ASP.NET Core web app that allows the user to drag and drop an image file on an HTML web page and post the image file to a C# Web API. The C# Web API saves the image to local disk.

Links to source code used in our videos can be found on our website:

Рекомендации по теме
Комментарии
Автор

This is exactly what I was after. You're a life saver.
I had a few false starts from other people's coding examples which seemed far more complicated.
I intend to extend the code to have an image display after the upload instead of the drag and and drop area.
I think the image data can still come back with the fileBundle (if I stringify a blob, but I might as well make a separate call).
I see it would be easy to adapt the code to allow loading multiple documents, which is just a matter of looping through the files array appending more files to the form data and modifying the controller to parse that array.
I will also thank you, as from a rudimentary glance, you appear to be using vanilla javascript and not jquery.
Once I have the code integrated I would like to send you a small monetary reward if there is a way. I'll let you know how I go.
If you're interested in the updated code, let me know, but I think any Dev could make the mods I intend to make.

AussieAmigan