Hi,
My database is showing null value when I try to insert the file path I upload.
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
String name=request.getParameter("fileUpload");
String destPath = "";
String relativeDestPath=getServletContext().getRealPath(destPath);
System.out.println("Relativepath is"+relativeDestPath);
PrintWriter out = response.getWriter();
String fileName=name.substring(name.lastIndexOf("\\"));
String pathName=name.substring(0,name.lastIndexOf("\\"));
String destName = relativeDestPath+fileName;
System.out.println(fileName);
System.out.println(pathName);
System.out.println(name);
System.out.println("Dest Name is "+destName);
UploadBean uBean = new UploadBean();
uBean.setFileName(destName);
boolean result = UploadProcess.uploadImage(uBean);
if(result)
{
FileInputStream fis = new FileInputStream(name);
FileOutputStream fos=new FileOutputStream(destName);
try
{
byte[] buf = new byte[1024];
int len;
while((len = fis.read(buf)) > 0){
fos.write(buf, 0, len);
}
System.out.println("Transfer successful");
}
catch (Exception e) {
// TODO: handle exception
System.out.println("In Exception");
}
//RequestDispatcher view=
}
}
}
Thanks for your help
Newcoder