Hello everybody,
I am trying to make simple upload file through html form
I used Jakarta Commons FileUpload
I have made the code typically like jakarta description :
====================upload.jsp=========================
<%@ page import="org.apache.commons.fileupload.*,java.util.*,java.io.*" %>
<%
// Check that we have a file upload request
boolean isMultipart = FileUpload.isMultipartContent(request);
// Create a new file upload handler
DiskFileUpload upload = new DiskFileUpload();
// Parse the request
List /* FileItem */ items = upload.parseRequest(request);
// Process the uploaded items
Iterator iter = items.iterator();
while (iter.hasNext())
{
FileItem item = (FileItem) iter.next();
if (item.isFormField()) {
out.println("hi , this is form based item "+item.getFieldName()+" "+item.getString()+"<BR>");
} else {
String fieldName = item.getFieldName();
String fileName = item.getName();
String contentType = item.getContentType();
boolean isInMemory = item.isInMemory();
long sizeInBytes = item.getSize();
InputStream uploadedStream = item.getInputStream();
uploadedStream.close();
out.println("hi , this is uploaded item "+item.getFieldName()+" "+item.getName()+" "+item.getName()+" "+item.getSize()+"<BR>");
}
}
%>
=========================================================
also this is the form i am using :
==============form.html=============
<form method="post" ACTION="upload.jsp" name="upform" ENCTYPE='multipart/form-data'>
<input type="file" name="uploadfile">
<p>
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Reset" value="Reset">
<input type="hidden" name="action" value="upload">
</form>
====================================
the upload.jsp works fine without errors , and generate some infromation about the file i want to upload , its name , its size ... but i don't know where this file is uploaded ???
i searched on the server just beside the upload.jsp page , but i didn't find any uploaded file !
can any one help me and tell me what i am missing in this code ?
or, if the file is really uploaded , where is it , and how i can define a specific place to upload it ?
thank you very much in advance