Reputation: 129
Using JSP am trying to move customer logo into another location in linux but its not working. thanks in advance
Here is my program
String customerLogo = request.getParameter("uploadCustomerLogo").trim();
StringBuffer absoluteFolderPath = new StringBuffer();
absoluteFolderPath.append("/zoniac");
absoluteFolderPath.append("/Companies/");
absoluteFolderPath.append("companyCode/");
absoluteFolderPath.append("custom/");
String destination = absoluteFolderPath.toString();
File sourcefile = new File(customerLogo);
File destfile = new File(destination+sourcefile.getName());
FileUtils.copyFile(sourcefile,destfile);
Upvotes: 1
Views: 1624
Reputation: 75346
I think you should learn how to run your JSP-code under a debugger. The ones in Eclipse and Netbeans (at least) work very well if properly set up.
You will most likely find that the values of sourcefile and destfile are not what you expect.
Also, your unchecked use of the uploadCustomerLogo is an exploit waiting to be found.
Upvotes: 0
Reputation: 467
This level of logic code really should go into the servlet. I think you need to take the stream of the file instead of just the file name. http://www.caucho.com/resin-3.0/jsp/tutorial/multipart.xtp http://www.roseindia.net/jsp/file_upload/index.shtml
Upvotes: 1
Reputation: 240860
Its better to write java code in servlet.
and this method will work, you need to provide physical path to file , it seems you are providing relative path in web context.
Upvotes: 1