I need to upload "1000 files" or "a zip file including all the files" at once using Struts2. (By 1000 Files or a zip file, I mean I need all the files to be uploaded on the system it does not matter if user choose all the 1000 files at once or zip them and upload as a single file, so I am looking for the one which is easier to implement and more efficient)
I have read the following answers but none of them suits the purpose.
Using the following code, when I use a simple List files; it shows name of lists, but when I use List files it does not show any thing and I can not upload the files.
upload.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<form action="upload" enctype="multipart/form-data" method="post">
<input name="files" type="file" multiple/>
<button type="submit"/>
</form>
</body>
</html>
upload.java
@Action
public class upload implements Addresses {
private List <File> files = new ArrayList <File> ();
public String execute(){
return "success";
}
public upload() {
System.out.println("in upload 1");
for(int i=0;i<files.size();i++)
System.out.println(i + ")" + files.get(i));
System.out.println("in upload 2");
}
public List <File> getFiles() {
return files;
}
public void setFiles(List <File> files) {
this.files = files;
for(int i=0;i<files.size();i++)
System.out.println(i + ")" + files.get(i));
// File fileToCreate = new File("c:\image", files.get(i).toString());
// FileUtils.copyFile(files.get(i), fileToCreate);
}
}
Output
in upload 1
in upload 2
<script language="JavaScript">
. How about<script type="text/javascript">
,<script type="application/javascript">
or even just<script>
? – Thermal