开发者

copy file from one location to another location in linux using java program

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/");

absolu开发者_如何转开发teFolderPath.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);


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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜