NodeJS FTP模块使用
模块说明:https://www.npmjs.com/package/ftp
上传文件
建立连接-> 判断文件夹是否存在->创建文件夹->上传文件->End
核心代码:
![](http://upload-images.jianshu.io/upload_images/5209409-22ce5769e3e90fd1.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
连接参数:
var targetOptions = {
host:config.upload.ftp.host,
port:config.upload.ftp.port,
user:config.upload.ftp.user,
password:config.upload.ftp.password
};
删除文件
![](http://upload-images.jianshu.io/upload_images/5209409-ea0358366262c062.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
下载文件
![](http://upload-images.jianshu.io/upload_images/5209409-a89ec7c91465bc42.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)