Click to See Complete Forum and Search --> : Multiple files upload
amrigo
11-25-2005, 11:55 AM
Hi
I need to do multiple files uploads with jsp, and record in a database a record with: file title typed by the user and the filename, because that the file will be stored on the filesystem of my tomcat context (data directory)
How it can be done ?
How do i get the filename to be able to record it in a database ?
I have a class that do the files uploads (more than one at once )
but the records are not being recorded!
Do the filenames come from the form i choose them ? if not how do i get the filename ?
Thank´s in advance
Khalid Ali
11-26-2005, 12:14 PM
Do the filenames come from the form i choose them ?if not how do i get the filename ?
Yes, when you upload a file using browser, you use html component named "file"
When a form is submitted(ofcourse the enctype="multipart/form-data") the file object converted to a stream is sent to the server, at this point server gets the file components name, file name and the stream alongwith it. you ca parse it using request.getParameter(fileFieldName)....
I have a class that do the files uploads (more than one at once )
but the records are not being recorded!
To add a record in the db, you need to have a database with a specifc table that will store the values, once that is done then u need a connection established between your web application and thats when u can set the record in db..if it sounds a bit complex? then just search google for db connection with java etc and u may find what u are looking for
amrigo
11-29-2005, 06:32 AM
Hi
I am uploading my multiple files now !
At this time to my system to be perfect i need to know :
How can i remove white spaces and accents from the filename and also assign a unique filename?
I try to use date :
String name = "";
Date d = new Date();
name += String.valueOf(d.getYear());
name += String.valueOf(d.getMonth());
name += String.valueOf(d.getDay());
name += String.valueOf(d.getHours());
name += String.valueOf(d.getMinutes());
name += String.valueOf(d.getSeconds());
name = name + "." + file.getFileExt();
But uploading multiple files all are uploaded at the same second so the filename will always be the same overriding one to another
How cabn i have unique filenames and remove white spaces and accents ?
Thank´s in advance