use*_*213 11 javascript ftp node.js
我正在尝试使用node.js在ftp服务器上传文件,如下所示 -
我正在使用library- https://github.com/sergi/jsftp
var fs = require('fs');
var Ftp = new JSFtp({
host: "ftp.some.net",
port: 21, // defaults to 21
user: "username", // defaults to "anonymous"
pass: "pass",
debugMode: true // defaults to "@anonymous"
});
Run Code Online (Sandbox Code Playgroud)
上传文件 -
exports.UploadToFtP = function (req, res) {
Ftp.put('public/Test.html', '/Test/index.html', function (err) {
if (!err)
res.send(200);
else
res.send(err);
});
};
Run Code Online (Sandbox Code Playgroud)
我尝试使用上面的方法上传文件,它回复了我200 OK
.但我在服务器上没有文件.这是否必须与服务器的连接时间有关?为什么这不是在服务器上写文件?
如果调试模式打开,jsftp 实例将发出 jsftp_debug 事件。
为了做出反应以打印所有调试事件,我们将监听如下调试消息:
Ftp.on('jsftp_debug', function(eventType, data) {
console.log('DEBUG: ', eventType);
console.log(JSON.stringify(data, null, 2));
});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7251 次 |
最近记录: |