Search code examples
javascripthtmlclipboardcopy-pasteclipboarddata

Copy files from web to desktop and reverse


I am building a web based file manager and was wondering, if it was possible to copy files from the web to the desktop and reverse.

Just like I can copy [CTRL] + [C] a file on my desktop and then paste [CTRL] + [V] it somewhere else.

I am thinking this is just a matter of what I send to the clipboard.

Anyone have any informations on this.


Solution

  • What you want to do is not hard, but it's not simple. Browser scripts have very tight controls over file system access (otherwise it would be very easy to put malware on a page that will read a user's entire hard drive). Generally, uploads need to be initiated by a user action. It's very hard to make files automatically upload or download, but a click event or drag and drop event can trigger what you want.

    You'll have a lot of research to do. Good places to start are MDN and Html5Rocks. (They're the top two on the list found by Googling "javascript file api", and both are great resources.)