Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Simulate' file download in HTML5 web app

Say I have a webapp which executes in its entirety on the client-side. Its purpose is to act as a file conversion utility, for example converting a user's local stored word document into a PDF.

So with the user's permission, the app can read a specified local file and process it, in memory, into PDF format.

How can I get the user to 'download' the result? since the data is held in the browser's memory anyway, I do not wish to upload it to some server.

[edit]

  • No flash based solutions
  • Expected file sizes to be up to 15mb
like image 529
greTech Avatar asked Jan 23 '13 09:01

greTech


People also ask

How do I trigger a download when clicking HTML button or Javascript?

Method 1: How to Trigger a File Download by Clicking an HTML Button? You need to utilize the <input> tag to create an HTML button and set its value to “Download”. The value is a user-defined attribute and can be set as per the user's wish. The script executes in the test.

How do I force download a link instead of open?

In most browsers, clicking on the link will open the file directly in the browser. But, if you add the download attribute to the link, it will tell the browser to download the file instead. The download attribute works in all modern browsers, including MS Edge, but not Internet Explorer.


1 Answers

The solution for my case will be to use the HTML5 FileSaver API.

Perhaps this question should just be closed as it is effectively a duplicate of

Using HTML5/Javascript to generate and save a file

Thanks to aefxx

like image 79
greTech Avatar answered Oct 04 '22 15:10

greTech