I’ve to send a file to my server using jQuery. How can I do it using JSON?
The file type is not important, I intend to receive a byteArray or something like that on my server application.
If it helps I’m using an ASP.NET application, but my problem is not the way I handle that on server side, the issue is how to send the file data using jQuery.
I’ve found some upload plugins for jQuery that use a Flash file, others that do not use Flash, but what I really want to know is how the process works, not just use something already created by someone!
jQuery is JavaScript. I think you mean to send the data via Ajax
which can not be done. The best thing you can do is to use an iframe to a page that uploads the file to a temporary directory (not the default temp), and then provides the information back to the parent page as to where the file is saved then you use it.There is no way to upload a file to a server using Ajax. It’s too insecure.
I retract the Statement above NOW
You are now able to post/download file data using Javascript it’s very complicated for a novice to understand but is now possible unlike when this question was answered
Using HTML5 file uploads with AJAX and jQuery