[Dojo-interest] “[File] Save As” Functionality

burnsmicro burnsmicro at gmail.com
Fri Jan 24 17:55:53 EST 2014

On 14-01-06 07:20 AM, Simon Speich [via Dojo Toolkit] wrote:
> What Karl wrote is still valid today. For security reasons you can't 
> write a file to a client directly through JavaScript. However, you can 
> write data locally using indexedDB on modern browsers, see 
> https://developer.mozilla.org/en-US/docs/IndexedDB
Thanks Simon, but I am out of my depth here.
> Depending on what you wan't to do, you can force the browser to 
> display a download dialog by responding with a 
> header('Content-Disposition: attachment; filename=myfile');

Thanks. It took me a while to figure it out, but it seems to work as 

First, I added a PHP file, SaveAs.php, to the [LAMP] server:


// The file will be named downloaded.doc in the browser's SaveAs dialog:

// readfile the file to be downloaded from the server:

..and I added a button to a test web page with the following OnClick() 
method, to get the server to execute SaveAs.php:

onClick: function( ) {
window.location = 'http://localhost/dev/dev/SaveAs.php';

View this message in context: http://dojo-toolkit.33424.n3.nabble.com/File-Save-As-Functionality-tp4000579p4000852.html
Sent from the Dojo Toolkit mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.dojotoolkit.org/pipermail/dojo-interest/attachments/20140124/4994ebce/attachment.htm 

More information about the Dojo-interest mailing list