sergi / jsftp

Light and complete FTP client implementation for Node.js
MIT License
807 stars 155 forks source link

put doesn't work #258

Open Luisadz24 opened 7 years ago

Luisadz24 commented 7 years ago

I have a problem when I tried to put a file in the fTP server, my program show me an error that is:

Error: Local file doesn't exist.
    at C:\Users\000\Documents\Trabajo\Mabe\Programas javascript\clienteftp\node_modules\jsftp\lib\jsftp.js:572:25
    at FSReqWrap.oncomplete (fs.js:112:15)

and my file exists, my code is the next (sorry for my bad english)

var JSFtp = require("jsftp");

var buffer='C:/Users/000/Documentos/frente0002.jpg';
var remote='/acm/img.jpg';

var Ftp = new JSFtp({
  host: 'ip',
  port: 21, // defaults to 21
  user: 'cliente',
  pass:'',
  debugMode: true  
});

Ftp.raw("cwd", "/",function(err, data) {
    if (err) return console.error(err);
     console.log("quede en cwd");
    console.log(data.text); // Show the FTP response text to the user
    console.log(data.code); // Show the FTP response code to the user

    Ftp.raw("pwd", "/new", function(err, data) {
    if (err) return console.error(err);
    console.log("quede en pwd");
    console.log(data.text); // Show the FTP response text to the user
    console.log(data.code); // Show the FTP response code to the user

             Ftp.put(buffer, remote, function(hadError) {
              if(hadError)return console.log(hadError);
                console.log("Archivo en servidor");

                 Ftp.raw("quit", function(err, data) {
                      if (err) return console.error(err);

                      console.log(data.text); // Show the FTP response text to the user
                      console.log(data.code); // Show the FTP response code to the user

                    });                

        });

  });    

});
sergi commented 6 years ago

What's the output of this code?