Isso é bem parecido com um dos exemplos que eu tentei…
Qdo tento usar o que você me passou, bem como todos os que tentei com essa biblioteca, aparece o seguinte erro:
java.lang.Error: Unresolved compilation problems:
The import org.apache.commons.io cannot be resolved
FileCleaningTracker cannot be resolved to a type
FileCleaningTracker cannot be resolved to a type
The method getFileCleaningTracker() from the type DiskFileItemFactory refers to the missing type FileCleaningTracker
FileCleaningTracker cannot be resolved to a type
FileCleaningTracker cannot be resolved to a type
FileCleaningTracker cannot be resolved to a type
FileCleaningTracker cannot be resolved to a type
Já configurei o .jar dentro do Build Path… não sei o que é…
J
Jonathan_p
não tinha colocado commons-io-1.2.jar, só a outra… :shock:
Vou baixar e adicionar aqui pra ver o que acontece.
Posta o Código da sua pagina JSP e da Class ai para verificar.
Ou se voc~e utilizou o modelo que mostrei…você add a class no pacote correto, aparentemente como se não encontrasse a class, ou algo do tipo.
J
Jonathan_p
utilizei o seu modelo… os .jars estão dentro do meu projeto e já configurei dentro do Eclipse…
já olhei aqui tudo, não sei o que eu posso estar fazendo errado…
THG_Carvalho
Tenta isso, aqui deu certo:
// the directory where the uploaded file will be saved. StringsavePath="C:\\123data\\";Stringfilename="";ServletInputStreamin=request.getInputStream();byte[]line=newbyte[128];inti=in.readLine(line,0,128);intboundaryLength=i-2;Stringboundary=newString(line,0,boundaryLength);//-2 discards the newline characterwhile(i!=-1){StringnewLine=newString(line,0,i);if(newLine.startsWith("Content-Disposition: form-data; name=\"")){Strings=newString(line,0,i-2);intpos=s.indexOf("filename=\"");if(pos!=-1){Stringfilepath=s.substring(pos+10,s.length()-1);// Windows browsers include the full path on the client // But Linux/Unix and Mac browsers only send the filename // test if this is from a Windows browser pos=filepath.lastIndexOf("\\");if(pos!=-1)filename=filepath.substring(pos+1);elsefilename=filepath;}//this is the file content i=in.readLine(line,0,128);i=in.readLine(line,0,128);// blank line i=in.readLine(line,0,128);ByteArrayOutputStreambuffer=newByteArrayOutputStream();newLine=newString(line,0,i);while(i!=-1&&!newLine.startsWith(boundary)){// the problem is the last line of the file content // contains the new line character. // So, we need to check if the current line is // the last line. buffer.write(line,0,i);i=in.readLine(line,0,128);newLine=newString(line,0,i);}try{// save the uploaded file RandomAccessFilef=newRandomAccessFile(savePath+filename,"rw");byte[]bytes=buffer.toByteArray();f.write(bytes,0,bytes.length-2);f.close();}catch(Exceptione){}}i=in.readLine(line,0,128);}// end while