How to upload a folder using IPFS API

Hi,

I want to add a folder (including all the files and subfolders in it) using the IPFS API. Please suggest a method for doing the same.

Currently I am using html and jquery to input the folder as shown below:-

html

<form id="file-catcher">
      <input id="file-input" type="file" webkitdirectory mozdirectory multiple>
          <p>Drag your folder here or click in this area</p>
      <button type="submit" name="upload">Upload</button>
</form>

JS/JQuery

$(document).ready(function() {
  $('form input').change(function () {
    $('form p').text(this.files.length + " file(s) selected");
  });
});

var inps = document.querySelectorAll('input');
[].forEach.call(inps, function(inp) {
  inp.onchange = function(e) {
    console.log(this.files);
  };
});   

Also, please suggest a method to handle the uploaded folder using javascript.

Thanks.

Hey, have you solved the issue? If yes, please share how did you do this?

How the different parts to the /add need to look like for ipfs to understand the file hierarchy is explained here: HTTP API | IPFS Docs.