Added python project; fixed spelling of folder
This commit is contained in:
65
Java Projects/jspUploader/jspUploader/Uploader.jsp
Normal file
65
Java Projects/jspUploader/jspUploader/Uploader.jsp
Normal file
@@ -0,0 +1,65 @@
|
||||
<%@ page import="org.apache.commons.fileupload.servlet.ServletFileUpload"%>
|
||||
<%@ page import="org.apache.commons.fileupload.disk.DiskFileItemFactory"%>
|
||||
<%@ page import="org.apache.commons.fileupload.*"%>
|
||||
<%@ page import="java.util.Iterator" %>
|
||||
<%@ page import="java.util.List" %>
|
||||
<%@ page import="java.io.File" %>
|
||||
|
||||
<%
|
||||
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
|
||||
String dirPath = getServletContext().getRealPath("/").replace('\\', '/') +
|
||||
"data/";
|
||||
String itemName;
|
||||
File file;
|
||||
|
||||
|
||||
out.println(
|
||||
"<!DOCTYPE html>"
|
||||
+ "<html><head>"
|
||||
+ "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />"
|
||||
+ "<title>Results</title>"
|
||||
+ "<link type=\"text/css\" rel=\"stylesheet\" href=\"resources/main.css\">"
|
||||
+ "</head> <body>"
|
||||
);
|
||||
|
||||
// Save file if present
|
||||
if (isMultipart) {
|
||||
FileItemFactory factory = new DiskFileItemFactory();
|
||||
ServletFileUpload upload = new ServletFileUpload(factory);
|
||||
List list = null;
|
||||
|
||||
try { list = upload.parseRequest(request);
|
||||
} catch (FileUploadException e) { out.println(e); }
|
||||
|
||||
Iterator itr = list.iterator();
|
||||
while (itr.hasNext()) {
|
||||
FileItem item = (FileItem) itr.next();
|
||||
if (!item.isFormField()) {
|
||||
try {
|
||||
itemName = item.getName();
|
||||
file = new File(dirPath + itemName);
|
||||
item.write(file);
|
||||
} catch (Exception e) { }
|
||||
}
|
||||
}
|
||||
} else {
|
||||
out.println("<h2 class=\"error\">Not multi-part transmitted...</h2>");
|
||||
}
|
||||
|
||||
// List directory
|
||||
File curentDir = new File(dirPath);
|
||||
String[] list = curentDir.list();
|
||||
for (int i=0; i<list.length; i++) {
|
||||
String name = list[i].toLowerCase();
|
||||
if (name.contains(".png") || name.contains(".jpg")||
|
||||
name.contains(".gif") || name.contains(".jpeg")) {
|
||||
out.print("<div class='file'>" +
|
||||
"<img class='thumbnail' src='data/" + list[i] +
|
||||
"'/></div>");
|
||||
} else {
|
||||
out.print("<a href='data/" + list[i] + "'/><div class='file'>" + list[i] + "</div></a>");
|
||||
}
|
||||
}
|
||||
|
||||
out.println("</body></html>");
|
||||
%>
|
14
Java Projects/jspUploader/jspUploader/WEB-INF/web.xml
Normal file
14
Java Projects/jspUploader/jspUploader/WEB-INF/web.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
|
||||
http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
|
||||
version="4.0"
|
||||
metadata-complete="true">
|
||||
|
||||
<display-name>File Uploader & Downloader</display-name>
|
||||
<description>
|
||||
File Uploader & Downloader
|
||||
</description>
|
||||
|
||||
</web-app>
|
Binary file not shown.
BIN
Java Projects/jspUploader/jspUploader/data/DarkCrypt.7z
Normal file
BIN
Java Projects/jspUploader/jspUploader/data/DarkCrypt.7z
Normal file
Binary file not shown.
Binary file not shown.
26
Java Projects/jspUploader/jspUploader/index.html
Normal file
26
Java Projects/jspUploader/jspUploader/index.html
Normal file
@@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<title>File Uploader</title>
|
||||
<link type="text/css" rel="stylesheet" href="resources/main.css">
|
||||
</head>
|
||||
<body onload="listDir()">
|
||||
|
||||
|
||||
<div class="container-center">
|
||||
<h2 class="h2Header">File Uploader</h2>
|
||||
<form action="Uploader.jsp" method="post" enctype="multipart/form-data" target="FormSubmitter">
|
||||
<input type="reset" value="Clear">
|
||||
<input type="submit" name="submit" value="⇧" />
|
||||
<input class="ulFile" type="file" name="file" data-multiple-caption="{count} files selected" multiple />
|
||||
</form>
|
||||
<form action="Uploader.jsp" method="post" enctype="multipart/form-data" target="FormSubmitter">
|
||||
<button type="submit" name="refresh">Refresh List</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<iframe id="FormSubmitter" name="FormSubmitter" frameborder="0" ></iframe>
|
||||
</body>
|
||||
</html>
|
48
Java Projects/jspUploader/jspUploader/resources/main.css
Normal file
48
Java Projects/jspUploader/jspUploader/resources/main.css
Normal file
@@ -0,0 +1,48 @@
|
||||
html, body {
|
||||
background-color: rgba(64, 64, 64, 1);
|
||||
width: 100%;
|
||||
margin: 0em;
|
||||
padding: 0em;
|
||||
}
|
||||
|
||||
#FormSubmitter {
|
||||
overflow: auto;
|
||||
width: 100%;
|
||||
min-height: 20em;
|
||||
margin-top: 1.5em;
|
||||
}
|
||||
|
||||
.h2Header, .ulFile { color: rgba(99, 179, 62, 1); }
|
||||
.file { background-color: rgba(164, 164, 164, 0.64); }
|
||||
|
||||
.container-center {
|
||||
width: 100%;
|
||||
margin: auto;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.dir, .file {
|
||||
display: block;
|
||||
float: left;
|
||||
width: auto;
|
||||
height: auto;
|
||||
margin: 0.5em;
|
||||
padding: 0.6em;
|
||||
min-width: 4em;
|
||||
min-height: 4em;
|
||||
}
|
||||
|
||||
.dir {
|
||||
background-color: rgba(34, 97, 128, 1);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.thumbnail {
|
||||
width: 8em;
|
||||
height: 4em;
|
||||
}
|
||||
|
||||
|
||||
.error { color: rgb(255, 0, 0); }
|
||||
.warnning { color: rgb(255, 168, 0); }
|
||||
.success { color: rgb(136, 204, 39); }
|
Reference in New Issue
Block a user