How upload a file with AngularJS, asp.net web API and fileupload saving to SQL

26,090

I've used ng-file-upload in quite a few Angular projects with no problems. It has comprehensive documentation and many examples to get you started.

The have recipes for the server side stuff too, here is one for .NET

This answer will help on the controller side in terms of getting the uploaded files into a byte array that you can then insert into the database of your choice.

Share:
26,090
RichardB
Author by

RichardB

Updated on July 11, 2022

Comments

  • RichardB
    RichardB almost 2 years

    I'm from a web forms background and learning angular with web API in C# and I have working site for adding/editing and deleting an object record. I know want to move on to more complex problems but struggling to know where to start!

    The nearest I've found is this post which seems quite good but limited to images but struggling to follow as its a bit confusing knowing which responses work. AngularJS .Net WebAPI Upload image and save to database (MSSQL).

    What I would like to do very simply is have an Object with properties Name (string) and Logo (Logo stored in db binary field). From and angular view save the object (calling route of my Web API) including validating the name and saving an image and if it already has one, display the current image.

    If anyone knows of a good simple example that will achieve that and ideally will work for any kind of file as some uploads in my site might be PDFs for example I would be hugely grateful.

  • WtFudgE
    WtFudgE almost 6 years
    the .net/angular example is awesome! a downloadable demo about file uploads that runs out of the box is rare to find