-
very strange problem with jakarta common file upload! pls help me!
hi
i just cant understnd why simple file upload is not working.
here is my code:
upload.jsp
=======
<html>
<head>
<title>Upload a file please</title>
</head>
<h1>Please upload a file</h1>
<form name="upload_ form" enctype="multipart/ form-data" method="post" action=http://mail.yahoo.com/config/login?/"/test/ upload.do">
<center>
<font face="tahoma" size="3">
Please choose a file to upload <input type="file" name="upload_ file">
<hr>
<input type="submit" name="bttn_submit" value="Upload File">
</font>
</center>
</form>
</html>
------------ --------- ---------
FileUploadServlet. java
============ ===
public void doPost (HttpServletRequest req,HttpServletResp onse res)throws ServletException, IOException{
// first check if the upload request coming in is a multipart request
boolean isMultipart = ServletFileUpload. isMultipartConte nt(req);
System.out.println( req.getContentTy pe());
// Create a factory for disk-based file items
FileItemFactory factory = new DiskFileItemFactory ();
// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload( factory);
// Parse the request
List items=null;
try {
items = upload.parseRequest (req);
} catch (FileUploadExceptio n e) {
// TODO Auto-generated catch block
e.printStackTrace( );
}
// Process the uploaded items
Iterator iter = items.iterator( );
while (iter.hasNext( )) {
FileItem item = (FileItem) iter.next();
// if (item.isFormField( )) {
// processFormField( item);
// } else {
// processUploadedFile (item);
// }
}
}
my problem is on the bold line. items = upload.parseRequest (req);
this method return a list which is empty!
very strange problem! so pls help me!
i copied this sample code from jakarta web site. but their code is not working!
i am using commonfileupload 1.1.1 jar file.
--chinmoy
Similar Threads
-
By sandhyaharsh in forum Java
Replies: 0
Last Post: 11-15-2005, 07:23 AM
-
Replies: 1
Last Post: 08-06-2005, 01:27 AM
-
Replies: 0
Last Post: 09-02-2002, 06:11 AM
-
Replies: 0
Last Post: 09-02-2002, 06:10 AM
-
By Paolo in forum VB Classic
Replies: 3
Last Post: 01-08-2001, 09:59 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|