Reputation: 58883
I have a simple form with some text inputs and a file input. I do not send it directly with a post, but I read each value of the text inputs with jQuery, compose a $.post request and send it to the server.
How can I do the same with a file <input type = "file" />
? I mean, sending it via ajax to a ASP.NET MVC page?
Thanks in advance
Upvotes: 2
Views: 631
Reputation: 3374
You can't. That would require javascript being able to read the file from your hard drive and send it to the website... the browser security model wouldn't allow for it.
You can do some javascript DOM trickery where have the file element in an iframe and use javascript to submit the form -- this is what google does with gmail. There are also flash methods of doing this.
James
Upvotes: 3