Thread: ftp_put error

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Posts
    286
    Rep Power
    13

    Angry ftp_put error


    I'm getting this when warning when I try the use the ftp_put command. It is : ftp_put: PORT command successful. in /......../web.cls.php on line 394. Every thing was working fine until a couple of days ago when it just stopped working.
    The connection seems to be opening ok, and then it hangs when trying to right the file.
    Can any one point me in the right direction of what is going wrong?
  2. #2
  3. Mobbing Gangster
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Sep 2001
    Location
    "Best City" 2002 and 2003- Melbourne, Australia
    Posts
    4,912
    Rep Power
    33
    ftp_put: PORT command successful. in /......../web.cls.php on line 394
    so you get that echoed when try to upload file? Does the file get uploaded? Weird, PORT is sort of alternative of PASS, and the difference between two is in the way how they do listing of dirs - somewhat different methods of getting info. Both of them have not much to do with file uploading, so you'll have to show some code.
    And you know I mean that.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Posts
    286
    Rep Power
    13
    Heres the code I'm using, two days ago it was working fine:

    function upload($page,$pageName)
    {
    //connect to remote host
    if(!($this->filetp=ftp_connect($this->ftp->host)))
    {
    print"ftp error";
    die;
    }
    if(!ftp_login($this->filetp,$this->ftp->login,$this->ftp->password))
    {
    print'login error<br>';
    }

    //create a temp. file
    if(!$file=fopen("temp".$this->id,"w")) {
    print"error creating page $pageName<br>";
    die;
    }

    fputs($file,$page);
    fclose($file);
    if(!ftp_put($this->filetp,$this->ftp->path."/$pageName","temp".$this->id, FTP_ASCII)) {
    print"error putting $pageName<br>";
    die;
    }

    //delete temp file
    unlink("temp".$this->id);

    //close ftp connection
    ftp_quit($this->filetp);
    }


    It creates the temp file no problems and even creates the file on the server it is uploading to. The Uploaded file is empty though
  6. #4
  7. Mobbing Gangster
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Sep 2001
    Location
    "Best City" 2002 and 2003- Melbourne, Australia
    Posts
    4,912
    Rep Power
    33
    Your logic is not very clear here, but lets go step by step.
    For debuging purposes let $this->id be 12. Your code does create temp12 file on hdd in the same dir as php file and file does have something in it. Then it uploads temp file to ftp, but it is empty there. By what name does it upload?
    And you know I mean that.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Posts
    286
    Rep Power
    13
    the uploaded page name is $pageName, for example index.php.
  10. #6
  11. Mobbing Gangster
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Sep 2001
    Location
    "Best City" 2002 and 2003- Melbourne, Australia
    Posts
    4,912
    Rep Power
    33
    Uhm. I do see one problem in your problem. Why bother uploading files anyway? Why don't you just write $page into $pageName without using extra ftp connection? I mean, couldn't you just use fopen and fputs? That'll make things faster and easier...
    And you know I mean that.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Posts
    286
    Rep Power
    13
    That could be a better solution, I'll give it a try thanks for the help.

IMN logo majestic logo threadwatch logo seochat tools logo