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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -