469,644 Members | 1,929 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,644 developers. It's quick & easy.

XMLHttpRequest / JavaScript to download files from server to local

2
I am looking for an isolated piece of code that uses XmlHttpRequest/JavaScript to download files from a (specified path on a) server to local machine. The browser on the local machine (Mozilla/FireFox) does not require user interaction.
Oct 18 '08 #1
4 15057
Atli
5,058 Expert 4TB
So you want your browser to download files and save them to the hard drive on your clients computer? And to top that, you want to do this without the user even being aware of it?

If so, then no mate. Never going to happen.

Could you imagine what would happen if web-developers could simply save stuff on your computer without you agreeing to it or even being aware of it? No computer connected to the internet would survive for more than a day.

No browser will ever give your client-side scripts access to the file-system.
Oct 18 '08 #2
robain
2
So you want your browser to download files and save them to the hard drive on your clients computer? And to top that, you want to do this without the user even being aware of it?

If so, then no mate. Never going to happen.

Could you imagine what would happen if web-developers could simply save stuff on your computer without you agreeing to it or even being aware of it? No computer connected to the internet would survive for more than a day.

No browser will ever give your client-side scripts access to the file-system.
No, the device with the browser is not a client or customer machine, but a dedicated device to reproduce multimedia content. Basically it´s a media player. It is programmed not to require user interaction, as the only controller of the dedicated device is also the controller of the server. Can you not work with server sockets on both sides, so that the server always accepts requests from player and vice versa. The only thing missing then is still the code on how to do this (download file from server to player via HTTP).

Here goes some comment from the device/software manufacturer:

+++
There is a way to do that [..initiate download from player]. That way is a standard way for Mozilla (or Firefox) based browsers.

You can use TCP sockets in your JavaScript applications like you usually do in C or any other general purpose language. See http://www.xulplanet.com/tutorials/mozsdk/sockets.php

You even can use server sockets in JavaScript. See http://www.xulplanet.com/tutorials/m...serverpush.php

You also can access local file system. See http://developer.mozilla.org/en/Code.../File_I%2f%2fO

You can also take a look at Mozilla jslib http://jslib.mozdev.org/

All this code requires interaction with user to ask him if he allows to perform the operation. In our player-browser [Mozilla/Firefox] this interaction is not required.

All these operations are allowed by default.
+++
The thing is I am just not a programming expert, and want only to have the right code to execute this operation.

Thanks a lot.
Oct 18 '08 #3
rnd me
427 Expert 256MB
you can use flash for sockets.

you can load remote files into variables, but you cannot save them on the local machine.

although in firefox and IE8, you can store up to 5mb of data using window.globalStorage.

you can store 10mb w/o permission by tunneling into flash.
Oct 20 '08 #4
akarsh
3
I don't know that which server side technology you are using. But if u are trying it in PHP then at first you have to make a request to your server using XMLHttpRequest object and on the server end you have to read that file's content using readfile() function. Then you should set some headers like content-type, pragma and Cache-control etc and finally echo that content on your web page using PHP 'echo' .
Oct 22 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Matt Hamilton | last post: by
2 posts views Thread by Grant | last post: by
6 posts views Thread by Michael Tissington | last post: by
reply views Thread by tanyali | last post: by
nathj
12 posts views Thread by nathj | last post: by
1 post views Thread by samvb | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.