Skip to content
Advertisement

Upload file to an IIS server with AJAX using HTML and JavaScript

I want to be able to upload an image file (.png, .jpg, etc..) to my web-server (running IIS Server with ASPX) using nothing but HTML and AJAX.

Here’s the code:

JavaScript
JavaScript
JavaScript

I’ve heard that enctype=”multipart/form-data” works, but clearly doesn’t in my case…

What should I do in order for my AJAX code to upload the image file?

Advertisement

Answer

Turns out I needed a FormData object, and add a file onto it, along with other things, since I was using AJAX.

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement