Ajax post file download


















I now store base64 strings into the database using longtext or longblog fields , then I pass its record ID through the jQuery File Download, finally on the download script file I query the database using this ID to pull the base64 string and pass it through the download function. I know this is way beyond what the OP asked, however I felt it would be good to update my answer with my findings.

I want to point out some difficulties that arise when using the technique in the accepted answer, i. Well, you can use a cookie that gets set on response, as done by jquery. You can only use the content types supported by a form. I ended up using the method of saving the file on S3 and sending a pre-signed URL to get the file. As others have stated, you can create and submit a form to download via a POST request. One really simple library for doing exactly this is jquery.

It provides an API similar to the standard jQuery. This is a 3 years old question but I had the same problem today. I looked your edited solution but I think that it can sacrifice the performance because it has to make a double request.

This form is just used to call the service and avoid to use a window. After that you just simply have to make a form submit from jquery in order to call the service and get the file. I used this FileSaver. URL window. Browser Compatibility. View Demo. Related Articles. Add Comments. Thank you for the feedback. The comment is now awaiting moderation.

You will be notified via email when the author replies to your comment. I already debugged and ensured that it was working but it simply comes to the response and does nothing Add a comment. Active Oldest Votes.

Improve this answer. I tried everything that I found on internet. But just your code worked. Thank you so much. The other things that I tried made my. After searching and trying a lot, this solution works perfect. Thanks binaryEcon — Francisco Ghelfi. Sign up or log in Sign up using Google. Majid Qafouri.

Awesome work!!! Keep it up Thanks from Argentina MarceloGuy Sep You code helped me so much. Thanks genius. Marcelo Guy. Re: Thanks from Argentina winsonet Nov Thank Elvin Acevedo Jun Elvin Acevedo.



0コメント

  • 1000 / 1000