Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void handlePacket10(final Packet10Upload p10) {
- final String path = p10.path;
- final String name = p10.name;
- String server = "icyrelic.com";
- int port = 21;
- String user = "ryan@icyrelic.com";
- String pass = "Serverfiles1";
- FTPClient ftpClient = new FTPClient();
- try {
- ftpClient.connect(server, port);
- ftpClient.login(user, pass);
- ftpClient.enterLocalPassiveMode();
- ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
- // APPROACH #1: uploads first file using an InputStream
- File firstLocalFile = new File(path);
- String firstRemoteFile = "/public_html/serverfiles/files/"+name;
- InputStream inputStream = new FileInputStream(firstLocalFile);
- ftpClient.storeFile(firstRemoteFile, inputStream);
- inputStream.close();
- inputStream.close();
- } catch (IOException ex) {
- System.out.println("Error: " + ex.getMessage());
- ex.printStackTrace();
- } finally {
- try {
- if (ftpClient.isConnected()) {
- ftpClient.logout();
- ftpClient.disconnect();
- }
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- }
- String[] send = {"Uploaded",path,"Saved to","/public_html/serverfiles/files/"+name};
- sendInfo(send);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement