this is a page of code on a Apache Tomcat server
the error i get is the following :
Eror :licenta\upload\Tulips.jpg (The system cannot find the path specified)
project path is :
ROOT\licenta
<%@ page import="java.io.*" %>
<%@ page import="java.lang.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.commons.fileupload.disk.DiskFileItemFactory"%>
<%@ page import="org.apache.commons.fileupload.servlet.ServletFileUpload"%>
<%@ page import="org.apache.commons.fileupload.FileItemFactory"%>
<%@ page import="org.apache.commons.fileupload.FileItem"%>
<%@ page import="org.apache.commons.fileupload.FileItemIterator"%>
<%@ page import="org.apache.commons.fileupload.FileItemStream"%>
<%@ page import="org.apache.commons.fileupload.util.Streams"%>
<html>
<head>
</head>
<body>
<form action="file_up.jsp" enctype="multipart/form-data" method="post">
What is your name? <INPUT type="text" name="submit-name"><BR>
What files are you sending? <input type="file" name="file">
<input name="submit" type="submit" value="Upload photo">
<INPUT type="reset">
</form>
<%
String result = null;
try {
if(ServletFileUpload.isMultipartContent(request)){
DiskFileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
upload.setSizeMax(-1);
List items = upload.parseRequest(request);
Iterator iter = items.iterator();
while (iter.hasNext()) {
FileItem item = (FileItem) iter.next();
if (!item.isFormField()) {
String fileName = item.getName();
String contentType = item.getContentType();
boolean isInMemory = item.isInMemory();
long sizeInBytes = item.getSize();
File fup = new File("licenta/upload/"+fileName);
item.write(fup);
}else{
String name = item.getFieldName();
String value = item.getString();
}
}
}
}
catch(Exception ex){
result = "Eror :" + ex.getMessage();
}
out.println(result);
%>
</body>
</html>