日期:2014-05-20  浏览次数:20611 次

ftp上传问题,求大神指教,真的挺急!!!
问题是这样的,我在类的main方法里面写了一个ftp上传的方法,没问题可以实现,我们现在有个ftp服务器,
但是我写成项目,部署到linux环境下后,就不行了,
用main方法上传能成功,因为文件就在本地,而部署到环境下后,文件在客户端了,
不知道大家能不能明白我说的,
其实很简单,就是web上怎么调用ftp的方法,上传文件。
我的核心方法:
 public static boolean uploadFiles(String remoteFile,File localFile,String path) {
        boolean flag=false;
        OutputStream out=null;
        try
        {
            //Tools.getRootPath()+path为客户端本地的文件路径
            File f=new File(Tools.getRootPath()+path);
            if(!f.exists()){
                f.mkdirs();
            }
            ftp.cwd(path);
            RandomAccessFile raf=new RandomAccessFile(localFile,"r");
            out=ftp.appendFileStream(new String(remoteFile.getBytes("utf-8"),"iso-8859-1"));
            byte[] bytes = new byte[1024];
            int c=0;
            //开始上传
                while((c = raf.read(bytes))!= -1){   
                    out.write(bytes,0,c);   
                      out.flush();   
                }   
             if(c==-1){
                 flag=true;
             }
        }
        catch (Exception e)
        {
            e.printStackTrace();