String TMP_DIR_PATH = "c:\\tmp";
File tmpDir = new File(TMP_DIR_PATH);
String[] lines = null;
int count = 0;
String size = null;
String key = null;
String userid = null;
String filename = null;
String nameid="";
String master="";
String sec="";
String pub="";
try {
DiskFileItemFactory fileItemFactory = new DiskFileItemFactory();
fileItemFactory.setSizeThreshold(1 * 1024 * 1024); //1 MB
fileItemFactory.setRepository(tmpDir);
ServletFileUpload uploadHandler = new ServletFileUpload(fileItemFactory);
List items = uploadHandler.parseRequest(request);
Iterator itr = items.iterator();
int a1;
int a2;
while (itr.hasNext()) {
FileItem item = (FileItem) itr.next();
if (item.isFormField()) {
// if (item.getFieldName().equals("key_")) {
// key = item.getString();
// }
} else {
String str = IOUtils.toString(item.getInputStream(), "UTF-8");
filename = item.getName();
//item.getInputStream().
lines = str.split("\r\n|\r|\n");
nameid= (String)session.getAttribute("userid");
sec=Utilities.stringtoByte(filename+filename.length());
pub=Utilities.stringtoByte(nameid);
master=Utilities.stringtoByte(pub+sec);
// a1=Utilities.stringtoByte(filename);
// a2=Utilities.stringtoByte(filename.length()+"");
// master= Integer.toBinaryString((a1&a2));
// size = lines.length + "";
}
}
} catch (Exception e) {
e.printStackTrace();
我在行
中收到错误List items=uploadHandler.parseRequest(request)
它说httpservletrequest cannot be converted to requestcontext
。我不知道如何解决这个错误。