Created
November 9, 2018 11:13
-
-
Save josemariagarcia95/250acdc8171c0e7b3d92d73cf361fd00 to your computer and use it in GitHub Desktop.
Code snippet to upload files to FTP server using Node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Ftp = require( 'ftp' ); | |
const ftpClient = new Ftp(); | |
ftpClient.on( 'ready', function() { | |
ftpClient.put( './prueba.jpg', '/www/img/prueba.jpg', function( err, list ) { | |
if ( err ) throw err; | |
ftpClient.end(); | |
} ); | |
} ); | |
ftpClient.connect( { | |
'host': '*****************', | |
'user': '***************', | |
'password': '**************' | |
} ); |
Hi @lindalima,
The library is the one called ftp. The one you got ("basic-ftp") probably doesn't use the same syntax as this snippet.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Error: Cannot find module 'ftp'.
Is FTP not standard in nodejs?
I learned now, Node.js does not come with a built-in FTP module as part of its standard library.
Where do I find a third-party FTP modules?
I installed with "npm install basic-ftp"