Upload files in folder/subdirectories using webkitDirectory and Java Servlet
<p>I am trying to implement a file-upload functionality using webkitdirectory with java backend.</p>

<p>Step1. Design a HTML form with webkitdirectory</p>

<pre><code>&lt;form action="DataUpload" method="post" enctype="multipart/form-data"&gt;
&lt;input type="text" name="dbName" value="Database Name Here" id="dbName"/&gt;
    &lt;input type="file" id="ctrl" webkitdirectory directory multiple/&gt;
    &lt;input type="submit" /&gt;
&lt;/form&gt;
</code></pre>

<p>Step 2. Passing information from <code>form</code> to <code>Servlet</code></p>

<pre><code>public class DataUpload extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response){

    ServletFileUpload upload = new ServletFileUpload();
    FileItemIterator fileIterator;
    try {
        fileIterator = upload.getItemIterator(request);
        InputStream inputStream = null;
        BufferedReader br = null;
        System.out.println("CheckPoint 1");
        while(fileIterator.hasNext()) {
            System.out.println("CheckPoint 2");
            FileItemStream item = fileIterator.next();
            String inputFileName = FilenameUtils.getName(item.getName());
            inputStream = item.openStream();

            inputFileName = inputFileName.split("\\.")[0];
            List&lt;String[]&gt; list = new ArrayList&lt;String[]&gt;();                
            // Getting File
            br = new BufferedReader(new InputStreamReader(inputStream));    // Getting the object to read file
            String line;
            while((line = br.readLine())!= null){// While condition ends then end of file is reached.
                list.add(line.split(","));
            }
            // Checking if File is Empty
            if (list.size() == 0){
                System.err.println("File Empty");
            }else{
                // TODO : Parameter Parser.
                // DO JOB HERE
            }           
        }
    } catch (FileUploadException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
</code></pre>

<p>My code, doesn't give any programming error, but it does not pass through the <code>CheckPoint 2</code>, i.e. it doesn't go inside the <code>while</code> loop. I tried looking into various post, such as:</p>

<p><a href="http://sapphion.com/2012/06/12/keep-directory-structure-when-uploading/" rel="nofollow noreferrer">Keep Directory Structure When Uploading</a><br/>
<a href="https://stackoverflow.com/questions/2422468/how-to-upload-files-to-server-using-jsp-servlet">How to upload files to server using JSP/Servlet?</a> - While this question shows maximum resemblance to problem in question, <a href="https://stackoverflow.com/questions/2422468/how-to-upload-files-to-server-using-jsp-servlet">This</a> question works for selecting multiple files in a folder, where the problem here is question is to upload files in different sub directories inside a folder.</p>

<p>I was wondering, if this was possible using solely <code>java servlets</code> without using <code>javascript</code>. I was able to upload multiple files inside a single folder. But, code doesn't seem to work, when I select a folder as input, instead it works when I select a particular file or a subset of files.</p>