0

I can select two folders as below.

 <input type="file" id="file-input-one" webkitdirectory="" directory="">
 <input type="file" id="file-input-two" webkitdirectory="" directory="">

I want to copy/move all files from 1st folder to 2nd. I can read files inside first directory as below. I can also get the full path of the second directory as well. How do I copy files?

    jQuery(function($) { 
    $('#file-input-one').on('change', function() {
        $.each(this.files, function(i, file) {
      //move each file to second folder.
        }
    })
})
Noob
  • 57
  • 3
  • 12
  • 4
    No, you can't do this via js. This would be a massive security issue. – CollinD Nov 08 '16 at 19:56
  • Even though when I am explicitly selecting source and destination locations? – Noob Nov 08 '16 at 19:56
  • 2
    This cannot be done on the client. However, if you had a node server running on the machine, it would be possible with javascript. – GPicazo Nov 08 '16 at 19:57
  • I also came across copying/moving files using HTML5 [here](https://www.html5rocks.com/en/tutorials/file/filesystem/). How is this different from what I asked? – Noob Nov 08 '16 at 19:58
  • 1
    That's a chrome-only API (that's been discontinued) and it looks like you can only work within a virtual filesystem space controlled by chrome and quota'd to a max size. If you want to do something like this exclusively in chrome, go for it. But it doesn't appear that there's a way to write to an arbitrary location like you're looking for. – CollinD Nov 08 '16 at 20:28
  • 1
    Potentially useful reading http://stackoverflow.com/questions/19802032/how-can-a-chrome-extension-save-many-files-to-a-user-specified-directory – CollinD Nov 08 '16 at 20:32
  • Thanks for the info. – Noob Nov 08 '16 at 20:56

0 Answers0