How? upload multiple files with jsp and save then in a mysql database
I want to upload multiple files from a jsp and save these files into a mysql database.
I'm relatively new to java. So what do I have to do?
Can anyone help me?
use the fileupload-api from apache.
Thanks for the answer,
Please, can you post a sample? I don't know how to use the fileupload api.
And what do I have to do to save uploaded files to a database?
Thanks in advance
If you just want to store the data in the database, have a look at my extensions to the fileupload api, which contain a utility class, that will provide you the formdata as a map:
Sorry, Stupid question
Which code has to be in my servlet?
Map parameters = ServletRequestUtil.readParameters(httpRequest);
//reading a file
byte  filedata = (byte ) parameters.get("file");
// read a normal parameter
String param = (String) parameters.get("name");
Isn't it possible to iterate through the map and save the filename and the file itself to the database?
of course you can iterate through the map, by using mymap.keySet().iterator(). this will give you the keys of the map, which you can use to get the corresponding values.
my example extensions don't support for filename lookup. the data is mapped to the name of the fileupload control. however, you can modify the Util class and put the data into the map by using the filenames. they are stored in the getName() method of the fileitems. but be aware: a user can upload multiple files with exact the same filename, what results in overwriting the data in the map.
Thanks so far.
I tried to store the files as blob in a mysql Database, but I don't know how the objects in the map become blobs.
Please, can you help me
By sandhyaharsh in forum Java
Last Post: 11-15-2005, 06:23 AM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center