2013-07-05 73 views
-2

嘿我想通过FTP使用java将文件上传到我的网络服务器上的一个名为'截图'的目录。我一直在使用这段代码,它说它成功地存储了文件并成功连接,但是当我通过cPanel检查我的截图目录时,我没有看到上传的文件有任何帮助?FTP使用Java上传文件

public static void uploadFilee() { 
       FTPClient client = new FTPClient(); 
       FileInputStream fis = null; 

       try { 
        client.connect("****************"); 
        client.login("********", "********"); 
        System.out.println("Connected Successfully"); 
        String filename = "C:/Users/Christian/Desktop/screenshots/img_" +   queueInfo.get("SessionID"); 
        fis = new FileInputStream(filename); 

        client.storeFile(filename, fis); 
        System.out.println("Stored File Successfully"); 
        client.logout(); 
       } catch (IOException e) { 
        System.out.println("Error_1"); 
        e.printStackTrace(); 
       } finally { 
        try { 
         if (fis != null) { 
          fis.close(); 
         } 
         client.disconnect(); 
        } catch (IOException e) { 
         System.out.println("Error_2"); 
         e.printStackTrace(); 
        } 
       } 
      } 

     ` 
+0

这与SQL或PHP有什么关系? – andrewsi

回答