Bear Bibeault wrote:That likely means your URL is malformed. What happens when you try to load that URL directly into the browser?
Bear Bibeault wrote:Also, why is your URL absolute, versus server-relative? You could run into CORS issues.
Bear Bibeault wrote:One problem I see (besides the code formatting which is all over the place) is that you are not stopping the default action of the form submission. If you want to make an Ajax call rather than actually submitting the form, you either need to call the preventDefault method of the event, or return false from the event handler.
Why aren't you using jQuery to do all this? Makes it tons easier.
Tim Holloway wrote:
Instead, when you have a web server, the file contents are embedded in the HttpResponse stream and the client decides what to do with that data. As I said, the client might choose to save the content in a file, but it might choose to open it in an application. The server cannot control what the client will do. Only the client can make that decision.
Dave Tolls wrote:
You'd normally loop over the input stream, reading into a byte buffer, then writing that buffer out to the output stream. Keep looping until the number of bytes read comes back as -1.