You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Gaston Escobar <ge...@451.com> on 2003/02/20 21:26:48 UTC
URGENT PROBLEM
I don't really know where to post this e-mail. I'm sorry in case I've made a
mistake.
I've tried to use the FileUpload package I downloaded. But in the example
code, it throws an error when I try to compile it.
This is the example code that comes with the package:
public void doPost(HttpServletRequest req, HttpServletResponse res)
{
FileUpload fu = new FileUpload();
// maximum size before a FileUploadException will be thrown
fu.setSizeMax(1000000);
// maximum size that will be stored in memory
fu.setSizeThreshold(4096);
// the location for saving data that is larger than
getSizeThreshold()
fu.setRepositoryPath("/tmp");
List fileItems = fu.parseRequest(req);
// assume we know there are two files. The first file is a small
// text file, the second is unknown and is written to a file on
// the server
Iterator i = fileItems.iterator();
String comment = ((FileItem)i.next()).getString();
FileItem fi = (FileItem)i.next();
// filename on the client
String fileName = fi.getFileName();
// save comment and filename to database
...
// write the file
fi.write("/www/uploads/" + fileName);
}
And this is the error my compiler throws:
UploadServlet.java:34: cannot resolve symbol
symbol : method getFileName ()
location: interface org.apache.commons.fileupload.FileItem
String fileName = fi.getFileName();
^
1 error
-----------------------
Please, help me. And in case this e-mail was not correctly posted here, tell
me where I could do that
Thank you very much
Re: URGENT PROBLEM
Posted by Schalk <sc...@volume4.co.za>.
Gaston
What are the fields that are submitted and do you submit sirectly to the
servlet or, is it imported into a jsp page.
Also do you have a file called file_uploaded.jsp to which this servlet will
try and redirect?
Kind Regards »
Schalk Neethling »
Volume4.Development.Multimedia.Branding
.emotionalize.conceptualize.visualize.realize
Tel: +27125468436
Fax: +27125468436
email: schalk@volume4.co.za
url: www.volume4.co.za
----- Original Message -----
From: "Gaston Escobar" <ge...@451.com>
To: "Jakarta Commons Users List" <co...@jakarta.apache.org>
Sent: Thursday, February 20, 2003 11:45 PM
Subject: RE: URGENT PROBLEM
> I tried your code, but now I'm having a problem in the line:
> List items = upload.parseRequest(req);
>
>
> The server produces an internal error in that line! Nothing appears in
> catalina.out neither. Do you know what can be happening?
> Thanks a lot
>
>
>
> -----Mensaje original-----
> De: Schalk [mailto:schalk@volume4.co.za]
> Enviado el: Jueves, 20 de Febrero de 2003 05:39 p.m.
> Para: Jakarta Commons Users List
> Asunto: Re: URGENT PROBLEM
>
>
> Gaston
>
> Try the code below:
> /**
> * uploadFile.java
> *
> * Created on December 11, 2002, 11:40 PM
> */
>
> package volume4.sharelite.fileManager;
>
> import java.io.*;
> import java.util.*;
> import java.lang.*;
> import org.apache.commons.fileupload.*;
> import java.net.*;
> import java.sql.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
>
> /** Main class
> */
> public class uploadFile extends HttpServlet {
>
>
>
> /** This string contains the information of your local
> * directory for testing your application locally.
> */
> public String folder = "/Program Files/Apache Tomcat
> 4.0/webapps/PersonnelFinance/fileShare/fileExchange/files/";
> /** This is the location of your temp folder when
> * testing the application locally.
> */
> public String temp = "/temp";
>
> /** This value is read from the web.xml file and represents your
chosen
> * database driver.
> */
> public String DRIVER;
>
> /** This value is read from the web.xml file and represents the URL
> * pointing to your database.
> */
> public String URL;
>
> /** This value is read from the web.xml file and represents the
username
> * for your database.
> */
> public String USER;
>
> /** This value is read from the web.xml file and represents the
password
> * for your database.
> */
> public String PASS;
>
> /** This field value is processed by the <CODE>isFormField()</CODE>
> method
> * if this return true. This represents the user for whom this file is
> intended.
> */
> public String recipient;
>
> /** This value represents the name of the field currently processed.
> *
> */
> public String fieldName;
>
> /** This value represents the data of the field currently processed.
> */
> public String fieldData;
>
> /** This value represents the name of the field currently processed.
> */
> public String fileName;
>
> /** This value represents the name of the field currently processed.
> */
> public String fileFieldName;
>
> /** This value represents the name of the field currently processed.
> */
> public String comment;
>
> //public String serverFolder =
>
"/var/www/vhosts/personnelfinance/webapps/Persfin/fileShare/fileExchange/fil
> es/";
> //public String serverTemp =
> "/var/www/vhosts/personnelfinance/webapps/Persfin/temp/";
> /** This value represents the name of the field currently processed.
> */
> public String filePath;
>
>
> /**
> * @throws ServletException */
> public void init() throws ServletException {
> ServletContext context = getServletContext();
> DRIVER = context.getInitParameter("DRIVER");
> URL = context.getInitParameter("PFURL");
> USER = context.getInitParameter("PFUSER");
> PASS = context.getInitParameter("PFPASS");
> }
>
> protected void processRequest(HttpServletRequest req,
> HttpServletResponse res)
> throws ServletException, java.io.IOException {
>
> res.setContentType("text/html");
> PrintWriter out = res.getWriter();
> Connection con = null;
>
> try {
>
> FileUpload upload = new FileUpload();
>
> upload.setSizeMax(400000000);
> upload.setSizeThreshold(4096);
> upload.setRepositoryPath(temp);
>
> List items = upload.parseRequest(req);
>
> Iterator iter = items.iterator();
> while (iter.hasNext()) {
> FileItem item = (FileItem) iter.next();
>
> if (item.isFormField()) {
>
> fieldName = item.getFieldName();
>
> if(fieldName.equals("recipient")) {
> fieldData = item.getString();
> recipient = fieldData;
> }
> else if(fieldName.equals("comment")) {
> fieldName = item.getFieldName();
> fieldData = item.getString();
> comment = fieldData;
> }
> System.out.println("recipient: ");
> System.out.println(recipient);
> System.out.println("comment: ");
> System.out.println(comment);
>
>
> } else {
>
> if(item.getName().equals("")) {
> System.out.println("forwarding");
> } else {
>
>
> fileName = item.getName();
> fileFieldName = item.getFieldName();
>
> StringTokenizer tokenizer = new StringTokenizer(fileName, "\\,
> :, /");
> int amount = tokenizer.countTokens();
> for (int i = 0; i < amount -1; i++) {
> tokenizer.nextToken();
> }
> String currentFile = tokenizer.nextToken();
> filePath = folder + currentFile;
>
> item.getInputStream();
> item.write(folder + currentFile);
>
> item.delete();
>
> Class.forName(DRIVER);
> con = DriverManager.getConnection(URL,USER,PASS);
> PreparedStatement stmt = con.prepareStatement
> ("INSERT INTO fileexchange (fileName, fileURI, comments,
toUser)
> " +
> "VALUES (?, ?, ?, ?)"
> );
>
> stmt.setString(1, currentFile);
> stmt.setString(2, filePath);
> stmt.setString(3, comment);
> stmt.setString(4, recipient);
>
> int result = stmt.executeUpdate();
> }
>
> }
> }
> res.sendRedirect("file_uploaded.jsp");
>
> } catch(FileUploadException fue) {
> fue.printStackTrace();
> out.println("There was and error when reading and writing the
file
> to the server.");
>
> } catch(Exception e) {
> e.printStackTrace();
> }
> }
>
> protected void doGet(HttpServletRequest req, HttpServletResponse res)
> throws ServletException, java.io.IOException {
> processRequest(req, res);
> }
>
> protected void doPost(HttpServletRequest req, HttpServletResponse res)
> throws ServletException, java.io.IOException {
> processRequest(req, res);
> }
> }
>
>
> Kind Regards »
> Schalk Neethling »
> Volume4.Development.Multimedia.Branding
> .emotionalize.conceptualize.visualize.realize
> Tel: +27125468436
> Fax: +27125468436
> email: schalk@volume4.co.za
> url: www.volume4.co.za
> ----- Original Message -----
> From: "Gaston Escobar" <ge...@451.com>
> To: <co...@jakarta.apache.org>
> Sent: Thursday, February 20, 2003 10:26 PM
> Subject: URGENT PROBLEM
>
>
> >
> > I don't really know where to post this e-mail. I'm sorry in case I've
made
> a
> > mistake.
> > I've tried to use the FileUpload package I downloaded. But in the
example
> > code, it throws an error when I try to compile it.
> > This is the example code that comes with the package:
> >
> > public void doPost(HttpServletRequest req, HttpServletResponse res)
> > {
> > FileUpload fu = new FileUpload();
> > // maximum size before a FileUploadException will be thrown
> > fu.setSizeMax(1000000);
> > // maximum size that will be stored in memory
> > fu.setSizeThreshold(4096);
> > // the location for saving data that is larger than
> > getSizeThreshold()
> > fu.setRepositoryPath("/tmp");
> >
> > List fileItems = fu.parseRequest(req);
> > // assume we know there are two files. The first file is a small
> > // text file, the second is unknown and is written to a file on
> > // the server
> > Iterator i = fileItems.iterator();
> > String comment = ((FileItem)i.next()).getString();
> > FileItem fi = (FileItem)i.next();
> > // filename on the client
> > String fileName = fi.getFileName();
> > // save comment and filename to database
> > ...
> > // write the file
> > fi.write("/www/uploads/" + fileName);
> > }
> >
> >
> > And this is the error my compiler throws:
> >
> > UploadServlet.java:34: cannot resolve symbol
> > symbol : method getFileName ()
> > location: interface org.apache.commons.fileupload.FileItem
> > String fileName = fi.getFileName();
> > ^
> > 1 error
> >
> > -----------------------
> >
> > Please, help me. And in case this e-mail was not correctly posted here,
> tell
> > me where I could do that
> > Thank you very much
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
RE: URGENT PROBLEM
Posted by Gaston Escobar <ge...@451.com>.
I tried your code, but now I'm having a problem in the line:
List items = upload.parseRequest(req);
The server produces an internal error in that line! Nothing appears in
catalina.out neither. Do you know what can be happening?
Thanks a lot
-----Mensaje original-----
De: Schalk [mailto:schalk@volume4.co.za]
Enviado el: Jueves, 20 de Febrero de 2003 05:39 p.m.
Para: Jakarta Commons Users List
Asunto: Re: URGENT PROBLEM
Gaston
Try the code below:
/**
* uploadFile.java
*
* Created on December 11, 2002, 11:40 PM
*/
package volume4.sharelite.fileManager;
import java.io.*;
import java.util.*;
import java.lang.*;
import org.apache.commons.fileupload.*;
import java.net.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
/** Main class
*/
public class uploadFile extends HttpServlet {
/** This string contains the information of your local
* directory for testing your application locally.
*/
public String folder = "/Program Files/Apache Tomcat
4.0/webapps/PersonnelFinance/fileShare/fileExchange/files/";
/** This is the location of your temp folder when
* testing the application locally.
*/
public String temp = "/temp";
/** This value is read from the web.xml file and represents your chosen
* database driver.
*/
public String DRIVER;
/** This value is read from the web.xml file and represents the URL
* pointing to your database.
*/
public String URL;
/** This value is read from the web.xml file and represents the username
* for your database.
*/
public String USER;
/** This value is read from the web.xml file and represents the password
* for your database.
*/
public String PASS;
/** This field value is processed by the <CODE>isFormField()</CODE>
method
* if this return true. This represents the user for whom this file is
intended.
*/
public String recipient;
/** This value represents the name of the field currently processed.
*
*/
public String fieldName;
/** This value represents the data of the field currently processed.
*/
public String fieldData;
/** This value represents the name of the field currently processed.
*/
public String fileName;
/** This value represents the name of the field currently processed.
*/
public String fileFieldName;
/** This value represents the name of the field currently processed.
*/
public String comment;
//public String serverFolder =
"/var/www/vhosts/personnelfinance/webapps/Persfin/fileShare/fileExchange/fil
es/";
//public String serverTemp =
"/var/www/vhosts/personnelfinance/webapps/Persfin/temp/";
/** This value represents the name of the field currently processed.
*/
public String filePath;
/**
* @throws ServletException */
public void init() throws ServletException {
ServletContext context = getServletContext();
DRIVER = context.getInitParameter("DRIVER");
URL = context.getInitParameter("PFURL");
USER = context.getInitParameter("PFUSER");
PASS = context.getInitParameter("PFPASS");
}
protected void processRequest(HttpServletRequest req,
HttpServletResponse res)
throws ServletException, java.io.IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
Connection con = null;
try {
FileUpload upload = new FileUpload();
upload.setSizeMax(400000000);
upload.setSizeThreshold(4096);
upload.setRepositoryPath(temp);
List items = upload.parseRequest(req);
Iterator iter = items.iterator();
while (iter.hasNext()) {
FileItem item = (FileItem) iter.next();
if (item.isFormField()) {
fieldName = item.getFieldName();
if(fieldName.equals("recipient")) {
fieldData = item.getString();
recipient = fieldData;
}
else if(fieldName.equals("comment")) {
fieldName = item.getFieldName();
fieldData = item.getString();
comment = fieldData;
}
System.out.println("recipient: ");
System.out.println(recipient);
System.out.println("comment: ");
System.out.println(comment);
} else {
if(item.getName().equals("")) {
System.out.println("forwarding");
} else {
fileName = item.getName();
fileFieldName = item.getFieldName();
StringTokenizer tokenizer = new StringTokenizer(fileName, "\\,
:, /");
int amount = tokenizer.countTokens();
for (int i = 0; i < amount -1; i++) {
tokenizer.nextToken();
}
String currentFile = tokenizer.nextToken();
filePath = folder + currentFile;
item.getInputStream();
item.write(folder + currentFile);
item.delete();
Class.forName(DRIVER);
con = DriverManager.getConnection(URL,USER,PASS);
PreparedStatement stmt = con.prepareStatement
("INSERT INTO fileexchange (fileName, fileURI, comments, toUser)
" +
"VALUES (?, ?, ?, ?)"
);
stmt.setString(1, currentFile);
stmt.setString(2, filePath);
stmt.setString(3, comment);
stmt.setString(4, recipient);
int result = stmt.executeUpdate();
}
}
}
res.sendRedirect("file_uploaded.jsp");
} catch(FileUploadException fue) {
fue.printStackTrace();
out.println("There was and error when reading and writing the file
to the server.");
} catch(Exception e) {
e.printStackTrace();
}
}
protected void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, java.io.IOException {
processRequest(req, res);
}
protected void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, java.io.IOException {
processRequest(req, res);
}
}
Kind Regards »
Schalk Neethling »
Volume4.Development.Multimedia.Branding
.emotionalize.conceptualize.visualize.realize
Tel: +27125468436
Fax: +27125468436
email: schalk@volume4.co.za
url: www.volume4.co.za
----- Original Message -----
From: "Gaston Escobar" <ge...@451.com>
To: <co...@jakarta.apache.org>
Sent: Thursday, February 20, 2003 10:26 PM
Subject: URGENT PROBLEM
>
> I don't really know where to post this e-mail. I'm sorry in case I've made
a
> mistake.
> I've tried to use the FileUpload package I downloaded. But in the example
> code, it throws an error when I try to compile it.
> This is the example code that comes with the package:
>
> public void doPost(HttpServletRequest req, HttpServletResponse res)
> {
> FileUpload fu = new FileUpload();
> // maximum size before a FileUploadException will be thrown
> fu.setSizeMax(1000000);
> // maximum size that will be stored in memory
> fu.setSizeThreshold(4096);
> // the location for saving data that is larger than
> getSizeThreshold()
> fu.setRepositoryPath("/tmp");
>
> List fileItems = fu.parseRequest(req);
> // assume we know there are two files. The first file is a small
> // text file, the second is unknown and is written to a file on
> // the server
> Iterator i = fileItems.iterator();
> String comment = ((FileItem)i.next()).getString();
> FileItem fi = (FileItem)i.next();
> // filename on the client
> String fileName = fi.getFileName();
> // save comment and filename to database
> ...
> // write the file
> fi.write("/www/uploads/" + fileName);
> }
>
>
> And this is the error my compiler throws:
>
> UploadServlet.java:34: cannot resolve symbol
> symbol : method getFileName ()
> location: interface org.apache.commons.fileupload.FileItem
> String fileName = fi.getFileName();
> ^
> 1 error
>
> -----------------------
>
> Please, help me. And in case this e-mail was not correctly posted here,
tell
> me where I could do that
> Thank you very much
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: URGENT PROBLEM
Posted by Schalk <sc...@volume4.co.za>.
Gaston
Try the code below:
/**
* uploadFile.java
*
* Created on December 11, 2002, 11:40 PM
*/
package volume4.sharelite.fileManager;
import java.io.*;
import java.util.*;
import java.lang.*;
import org.apache.commons.fileupload.*;
import java.net.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
/** Main class
*/
public class uploadFile extends HttpServlet {
/** This string contains the information of your local
* directory for testing your application locally.
*/
public String folder = "/Program Files/Apache Tomcat
4.0/webapps/PersonnelFinance/fileShare/fileExchange/files/";
/** This is the location of your temp folder when
* testing the application locally.
*/
public String temp = "/temp";
/** This value is read from the web.xml file and represents your chosen
* database driver.
*/
public String DRIVER;
/** This value is read from the web.xml file and represents the URL
* pointing to your database.
*/
public String URL;
/** This value is read from the web.xml file and represents the username
* for your database.
*/
public String USER;
/** This value is read from the web.xml file and represents the password
* for your database.
*/
public String PASS;
/** This field value is processed by the <CODE>isFormField()</CODE>
method
* if this return true. This represents the user for whom this file is
intended.
*/
public String recipient;
/** This value represents the name of the field currently processed.
*
*/
public String fieldName;
/** This value represents the data of the field currently processed.
*/
public String fieldData;
/** This value represents the name of the field currently processed.
*/
public String fileName;
/** This value represents the name of the field currently processed.
*/
public String fileFieldName;
/** This value represents the name of the field currently processed.
*/
public String comment;
//public String serverFolder =
"/var/www/vhosts/personnelfinance/webapps/Persfin/fileShare/fileExchange/fil
es/";
//public String serverTemp =
"/var/www/vhosts/personnelfinance/webapps/Persfin/temp/";
/** This value represents the name of the field currently processed.
*/
public String filePath;
/**
* @throws ServletException */
public void init() throws ServletException {
ServletContext context = getServletContext();
DRIVER = context.getInitParameter("DRIVER");
URL = context.getInitParameter("PFURL");
USER = context.getInitParameter("PFUSER");
PASS = context.getInitParameter("PFPASS");
}
protected void processRequest(HttpServletRequest req,
HttpServletResponse res)
throws ServletException, java.io.IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
Connection con = null;
try {
FileUpload upload = new FileUpload();
upload.setSizeMax(400000000);
upload.setSizeThreshold(4096);
upload.setRepositoryPath(temp);
List items = upload.parseRequest(req);
Iterator iter = items.iterator();
while (iter.hasNext()) {
FileItem item = (FileItem) iter.next();
if (item.isFormField()) {
fieldName = item.getFieldName();
if(fieldName.equals("recipient")) {
fieldData = item.getString();
recipient = fieldData;
}
else if(fieldName.equals("comment")) {
fieldName = item.getFieldName();
fieldData = item.getString();
comment = fieldData;
}
System.out.println("recipient: ");
System.out.println(recipient);
System.out.println("comment: ");
System.out.println(comment);
} else {
if(item.getName().equals("")) {
System.out.println("forwarding");
} else {
fileName = item.getName();
fileFieldName = item.getFieldName();
StringTokenizer tokenizer = new StringTokenizer(fileName, "\\,
:, /");
int amount = tokenizer.countTokens();
for (int i = 0; i < amount -1; i++) {
tokenizer.nextToken();
}
String currentFile = tokenizer.nextToken();
filePath = folder + currentFile;
item.getInputStream();
item.write(folder + currentFile);
item.delete();
Class.forName(DRIVER);
con = DriverManager.getConnection(URL,USER,PASS);
PreparedStatement stmt = con.prepareStatement
("INSERT INTO fileexchange (fileName, fileURI, comments, toUser)
" +
"VALUES (?, ?, ?, ?)"
);
stmt.setString(1, currentFile);
stmt.setString(2, filePath);
stmt.setString(3, comment);
stmt.setString(4, recipient);
int result = stmt.executeUpdate();
}
}
}
res.sendRedirect("file_uploaded.jsp");
} catch(FileUploadException fue) {
fue.printStackTrace();
out.println("There was and error when reading and writing the file
to the server.");
} catch(Exception e) {
e.printStackTrace();
}
}
protected void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, java.io.IOException {
processRequest(req, res);
}
protected void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, java.io.IOException {
processRequest(req, res);
}
}
Kind Regards »
Schalk Neethling »
Volume4.Development.Multimedia.Branding
.emotionalize.conceptualize.visualize.realize
Tel: +27125468436
Fax: +27125468436
email: schalk@volume4.co.za
url: www.volume4.co.za
----- Original Message -----
From: "Gaston Escobar" <ge...@451.com>
To: <co...@jakarta.apache.org>
Sent: Thursday, February 20, 2003 10:26 PM
Subject: URGENT PROBLEM
>
> I don't really know where to post this e-mail. I'm sorry in case I've made
a
> mistake.
> I've tried to use the FileUpload package I downloaded. But in the example
> code, it throws an error when I try to compile it.
> This is the example code that comes with the package:
>
> public void doPost(HttpServletRequest req, HttpServletResponse res)
> {
> FileUpload fu = new FileUpload();
> // maximum size before a FileUploadException will be thrown
> fu.setSizeMax(1000000);
> // maximum size that will be stored in memory
> fu.setSizeThreshold(4096);
> // the location for saving data that is larger than
> getSizeThreshold()
> fu.setRepositoryPath("/tmp");
>
> List fileItems = fu.parseRequest(req);
> // assume we know there are two files. The first file is a small
> // text file, the second is unknown and is written to a file on
> // the server
> Iterator i = fileItems.iterator();
> String comment = ((FileItem)i.next()).getString();
> FileItem fi = (FileItem)i.next();
> // filename on the client
> String fileName = fi.getFileName();
> // save comment and filename to database
> ...
> // write the file
> fi.write("/www/uploads/" + fileName);
> }
>
>
> And this is the error my compiler throws:
>
> UploadServlet.java:34: cannot resolve symbol
> symbol : method getFileName ()
> location: interface org.apache.commons.fileupload.FileItem
> String fileName = fi.getFileName();
> ^
> 1 error
>
> -----------------------
>
> Please, help me. And in case this e-mail was not correctly posted here,
tell
> me where I could do that
> Thank you very much
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
[fileupload] example code problem [WAS URGENT PROBLEM]
Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
hi Gaston
this is the right list but since it's for a number of components, the
convention is that you prefix your email with the component name. you
should also probably choose a better subject. for more details please read
httpL//jakarta.apache.org/site/mail.html and the mailing guidelines for
this list.
as far as your problem goes, the only thing i can think of is that you
have an old version of fileupload in your classpath. maybe some other
people will be able to give you a better answer.
- robert
On Thursday, February 20, 2003, at 08:26 PM, Gaston Escobar wrote:
>
> I don't really know where to post this e-mail. I'm sorry in case I've
> made a
> mistake.
> I've tried to use the FileUpload package I downloaded. But in the example
> code, it throws an error when I try to compile it.
> This is the example code that comes with the package:
>
> public void doPost(HttpServletRequest req, HttpServletResponse res)
> {
> FileUpload fu = new FileUpload();
> // maximum size before a FileUploadException will be thrown
> fu.setSizeMax(1000000);
> // maximum size that will be stored in memory
> fu.setSizeThreshold(4096);
> // the location for saving data that is larger than
> getSizeThreshold()
> fu.setRepositoryPath("/tmp");
>
> List fileItems = fu.parseRequest(req);
> // assume we know there are two files. The first file is a small
> // text file, the second is unknown and is written to a file on
> // the server
> Iterator i = fileItems.iterator();
> String comment = ((FileItem)i.next()).getString();
> FileItem fi = (FileItem)i.next();
> // filename on the client
> String fileName = fi.getFileName();
> // save comment and filename to database
> ...
> // write the file
> fi.write("/www/uploads/" + fileName);
> }
>
>
> And this is the error my compiler throws:
>
> UploadServlet.java:34: cannot resolve symbol
> symbol : method getFileName ()
> location: interface org.apache.commons.fileupload.FileItem
> String fileName = fi.getFileName();
> ^
> 1 error
>
> -----------------------
>
> Please, help me. And in case this e-mail was not correctly posted here,
> tell
> me where I could do that
> Thank you very much
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>