java - getServletContext().getRealPath("/") omitting forward slash (/) -
i'm trying upload file html file input.
i using apache commons fileupload , file uploads successfully. however, when try storing file path in mysql, storing without file path code:
string uploadfolder = getservletcontext().getrealpath("/"); string filename = new file(item.getname()).getname(); filepath = uploadfolder+"/"+filename; file uploadedfile = new file(filepath);
this how i'm trying store file.
sample filepath stored
c:userslashdesktopworkspace3.metadata.pluginsorg.eclipse.wst.server.core mp0wtpwebappsjavaecom/download doget.txt
i have no idea question about, correct way operations posted code doing follows:
file uploadfolder = new file(getservletcontext().getrealpath("/")); string filename = new file(item.getname()).getname(); // not sure what's going on here file uploadedfile = new file(uploadfolder, filename);
Comments
Post a Comment