• Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet-File-Upload

 
Final Desire
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
I want to upload until three PDF-Files from a Web-Formular on a network-drive.
After I pressed the search button of the web-formular, I want to choose one file (I have three search fields to upload until three files at the same time). After choosing, I want to press on submit and upload the files on the network-drive (every time the same directory). During saving, the files are to be zippt.
My problem is, how can I upload files with a web-formular? And how can I received the file-stream?
With my class, I�m be able to choose a file from my drive and save it (zipped) on an other. But it I dont know how I do this with a web-formular.
I hope someone understand my problem and help me.
thxalot
Final =)
My Sourcecode to read and zipped a file:
import java.io.*;
import java.util.zip.*;
public class Zippen {
public static void main(String[] args) {

try {

ZipOutputStream out = new ZipOutputStream(new FileOutputStream("C://Java/test.zip"));
byte[] buf = new byte[4096];
int len;
FileInputStream in = new FileInputStream("C://files//readinfiles//testfile.pdf");
out.putNextEntry(new ZipEntry("outtestfile.pdf"));
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
out.close();
in.close();
} catch (IOException e) {
System.err.println(e.toString());
}
}
}
 
Brahim Bakayoko
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to send the form using "multipart/form-data" for one thing.
check out http://www.servlets.com/cos/index.html for a file upload library.
 
Final Desire
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot, I will try it.
Final =)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!