top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Java: How to upload entire directory or folder to server from an HTML/JSP?

+2 votes
532 views

I have some work to deal with directory upload..We can do individual file upload, but I want to know entire directory upload which will contain multiple files...

posted Jan 3, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

1) There can be many ways but you can try to make a jar/zip/tar/gzip of the folder and upload that file instead of doing one by one and extract the same on the server. This will lead to an extra logic at the server.

2) You can try to upload recursively all single files included in that folder via "yourDir.listFiles()" something like:

public boolean uploadYourDir(...) { 
.... 
File[] subFiles = yourDir.listFiles(); 
if (subFiles != null && subFiles.length > 0) { 
for (File item : subFiles) { 
//generate corresponding remote file path, write urself 
String remotePath = createRemoteFilePath(); 

if (item.isFile()) { 
//simple one 
uploadSingleFile(); 
} else { 
//create corresponding DIR name on remote 
..... 
//call this method itself 
uploadYourDir(..); 
} 

..... 
} 
return isSuccess; 
}
answer Jan 7, 2015 by Salil Agrawal
Similar Questions
+3 votes

I am trying to debug a javascript file, which is used in a .jsp file. When I debug the using F12 in IE10 I did not find that particular file in the debugger tool.

Can anybody please tell, why that particular file is not showing even it is present in project folder location?

+3 votes

I am trying to upload files through html page in our Windows based server but I don't know how to take the files on remote server & save files there

...