Thread: php and ftp

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

    Join Date
    Apr 2001
    Posts
    73
    Rep Power
    14

    php and ftp


    I'm writing a what should be a simple ftp script for users to upload a gif or jpg image.

    this is what I have :
    PHP Code:
    <?php

    $ftp_link 
    "host";
    $ftp_user "username";
    $ftp_pass "password";
    $ftp_path "web/files/banners/";

    if(!
    $function) {

    }

    if(
    $function == "upload") {

      function 
    _ftpConnect() {
        
    $ftp_conn ftp_connect($ftp_link);
        
    ftp_login($ftp_conn$ftp_user$ftp_pass);
      return 
    $ftp_conn;
    }

      
    $r _ftpConnect();
      
    ftp_chdir($r$ftp_path);

      
    $upload ftp_put($r$upfile_name$fileFTP_BINARY);
      
      if(!
    $upload) {
      echo 
    "FAILED";
      } else {
      echo 
    "SUCCESS";
      }

      
    ftp_quit($r);
    }
    ?>
    My problem is that I get this error : Warning: Unable to find ftpbuf 0

    I have no idea what is means and it occurs on the lines with ftp commands accept for ftp_connect.

    If someone could tell me what I'm doing wrong or what the error means I would be most grateful
    http://www.myclantemplate.com
    We are what we repeatedly do, Excellence then is not something we do but a Habit.
  2. #2
  3. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,640
    Rep Power
    4476
    Why do you have your function declaration inside of a conditional? Just define it and call it if you need it.

    Where is $function defined? If it's not, then your function is never defined...

    Also, if you're going to use outside variables in your function, then you have to make them global.

    function whatever()
    {
    global $this;
    global $that;

    ...

    }

    etc... May be other things wrong, too, that's the first I noticed. i doubt you are even making a connection, you should check for that first.

    ---John Holmes...
    -- Cigars, whiskey and wild, wild women. --

IMN logo majestic logo threadwatch logo seochat tools logo