1

I have a node.js server which takes an image parameter from a form with a file input tag. It uses new formdata(this) to put it in the ajax request and returns a link to a dynamically generated image on the node.js server. I then have to visit that link to download the image. I want a way to do combine both of this call.

I found this thread which shows how you can send an ajax request to get an image. But it expects it in base64 encoding.

Is it possible to do ajax call to get an image while providing a formdata with an image, and have the return type gzip binary like how an image is normally returned and not base64?

Thanks

EDIT: I think I have to use this but not sure how.

Community
  • 1
  • 1
sneaky
  • 2,141
  • 9
  • 31
  • 38
  • Why do you want to use ajax to read your image? Would [this](http://stackoverflow.com/a/31237998/3702797) help you? – Kaiido Aug 19 '15 at 00:55
  • I dont think thas what I'm asking for. Basically I am making an ajax request to a node server which I can return an image, but how do I handle reading it in jquery? I also want to attach an image to my ajax request. – sneaky Aug 19 '15 at 01:06
  • The file input tag is a input file upload dialog for the user to select (from their local pc) an image to upload. The image being attached, is then sent to the server and modified and I want to return the modified image in the same request. The problem is how to write the jquery ajax so it supports reading a binary image, while also attaching an image to send. – sneaky Aug 19 '15 at 01:14
  • This is the way I am sending the ajax request http://stackoverflow.com/questions/21054052/is-there-a-better-way-to-get-html5-input-type-file-to-work-with-tinymce (`new FormData`). How do I get jquery to accept binary image as return type, and then how do I insert that into an img tag? – sneaky Aug 19 '15 at 01:17
  • http://stackoverflow.com/a/17682424/3702797 – Kaiido Aug 19 '15 at 01:26

0 Answers0