Hello i am making a servlet that gets the image from a
Everything in my servlet works fine. The only problem is that i want to know what is the name of the uploaded image so that i can store its full path in a database. How to i so that?
This is the code that upload the file but, it doesn't provide me the actual name of the original image. f.getName gives me the name of my tag.
Part f= request.getPart("imgCoverInserisci");
InputStream imageInputStream = f.getInputStream();
System.out.println("Path where image will be saved: "+request.getContextPath()+"/Immagini/");
/*returns null*/ String nomeFile=request.getParameter("imgCoverInserisci");
f.getName(); //return name of input tag
FileOutputStream out = new FileOutputStream ("C:\\Users\\Salvatore\\Documents\\NetBeansProjects\\TestFumettopoli\\web\\Immagini\\copertineFumetti\\"+nomeFile);
// write bytes taken from uploaded file to target file
int ch = imageInputStream.read();
while (ch != -1) {
out.write(ch);
ch = imageInputStream.read();
}
out.close();
imageInputStream.close();