如何在FTP服务器中显示文件

时间:2017-11-02 08:54:17

标签: java ftp

我是FTP的初学者,我在进行文件传输时遇到问题。正在进行文件传输到FTP服务器,一旦文件自动传输,文件将从FTP服务器中删除。

                String newfilename;
                FTPClient ftpClient = new FTPClient();
                FileInputStream fis = null; 
                /*
                    written few set of statement for fetching file name and storing filename in **newfilename** variable and storing the file in **fis(FileInputStream).**
                */
                System.out.println("posting file "+newfilename);
                /* 
                    **ftpClient** is entered in working directory, I mean FTP server directory.
                */
                if(newfilename.startsWith("CAP1"))
                {
                    ftpClient.storeFile(newfilename, fis); 
                    record1[0].setAddr1(newfilename); //storing filename in respective column of DB
                }
                else if(newfilename.startsWith("CAP2"))
                {
                    ftpClient.storeFile(newfilename, fis);
                    record1[0].setAddr2(newfilename); //storing filename in respective column of DB
                }
                else if(newfilename.startsWith("CAP3"))
                {
                    ftpClient.storeFile(newfilename, fis);
                    record1[0].setAddr3(newfilename); //storing filename in respective column of DB
                }

所以有人建议,我需要做些什么改变?

1 个答案:

答案 0 :(得分:0)

终于得到了解决方案。由于主要FTP服务器位于远程位置,一旦我们将图像上传到FTP服务器,由于某些FTP服务器设置,在几分之一秒内这些图像将移动到其他位置。由于这个原因,我无法从FTP服务器看到任何图像。