我正在使用我的android设备将图像传输到桌面。我正在使用xampp的filezilla。它说传输是传输正常,但是当我检查图像时,文件为空。我使用图片的URI,因为当我尝试base64时,它说它太大了。
var ftp = require('basic-ftp');
var fs = require('fs');
const client = new ftp.Client();
const dir = 'uploads/images/';
const rdStream = dir + 'x.jpg';
async function ftpServer(file,fileName){
try{
await client.access({
host: 'localhost',
port: '21',
user: 'handyman',
password: 'handyman',
secure: false,
})
await client.ensureDir(dir);
await client.uploadDir(dir);
await client.upload(fs.createReadStream(rdStream), fileName);
//await client.rename(await client.pwd()+'/'+file,await client.pwd()+'/'+fileName);
//await client.size(await client.pwd()+'/'+fileName);
}catch(error){
console.log(error);
}
client.close();
}
router.post('/upload/:userID', function(req,res){
var file = req.body.value;
var userID = req.params.userID;
var imgFile = file.split('/');
var img = imgFile[imgFile.length-1];
var fileName = userID +'.'+ img[1];
ftpServer(file,img).then(() => console.log('Hello'));
});