Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery/Javascript upload and download a file without a backend

Is is possible to download and upload a file in a JavaScript function without a backend server? I need to export and import a XML made by a JavaScript function. I would like to create button "Save xml" to save a file but I don't know if it is possible. By other hand I wish to upload a XML file directly to JavaScript. If it is not possible I will use a backend server just like a proxy.

like image 796
Tobia Avatar asked May 26 '26 14:05

Tobia


1 Answers

I think you could look in to the HTML5 file api. Based on what you said all file should never leave the domain of the browser or the webapp. I believe this could cause some problems the user would be forced to use the same browser to access files. Also HTML5 standards have still not been fully implemented by all major browsers, that would be another risk. However if you want to go down that route I provided some resources that may help. I would recommend hosting the files, not my project I don't know your use cases.

http://www.html5rocks.com/en/tutorials/file/dndfiles/

http://updates.html5rocks.com/2011/08/Saving-generated-files-on-the-client-side

http://updates.html5rocks.com/2011/08/Downloading-resources-in-HTML5-a-download

http://eligrey.com/demos/FileSaver.js/

like image 98
CubanAzcuy Avatar answered May 28 '26 04:05

CubanAzcuy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!