0

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>
2
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by bowmaster
0

can you give me an example?
in the documentation it says that a absolute path is one with / at the front
and i tried that too and got the same error.
i am working on Windows operating system but the server is apache tomcat
if it makes any difference
thank you for your time

Edited by bowmaster: n/a

0

If you working on Windows then absolute path would be drive letter with directions to file, example C:\Images\img01.jpeg

0

C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0\webapps\examples\images\
i pasted that from explorer
and got this error

An error occurred at line: 44 in the jsp file: /licenta/file_up.jsp
Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )

0

i replaced \ with \\ and it worked thank you very much
will try next to save in project folder

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.