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

    Join Date
    Apr 2001
    Location
    NYC
    Posts
    52
    Rep Power
    14

    ftp upload problems with ftp_put()


    hey,
    put together this script and everything works fine until I inserted the ftp_put() function. Heres the script:

    <?

    if ($submit)
    {
    $conn= ftp_connect("www.server.com");

    if (!$conn)
    {
    echo "Error: Could not login";
    exit;
    }

    $user="user";
    $pass="password";

    $login = ftp_login($conn, $user, $pass);

    if(!$login)
    {
    echo "Error: could not login as $user";
    ftp_quit($conn);
    exit;
    }

    $server_dir="tmp/";

    ftp_put($login, $server_dir, $userfile, FTP_ASCII);

    if ($userfile=="none")
    {
    echo "<font color=\"#ff0000\"><b>NO FILE SELECTED</font><br>please go back</b>";
    exit;
    }

    if ($userfile_size==0)
    {
    echo "uploaded file is zero in length";
    exit;
    }

    echo "<b>$userfile</b> Uploaded successfully <br><br>";
    }
    else
    {
    ?>
    <form enctype="multipart/form-data" action="<?php echo $PHP_SELF?>" method=post>
    <input type="hidden" name="MAX_FILE_SIZE" value="800000">
    <table bgcolor=#cccccc border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="95">
    <div align="right">
    Choose File: </div>
    </td>
    <td width="95">
    <input name="userfile" size="26" type="file">
    </td>
    </tr>
    <tr>
    <td width="95">&nbsp;</td>
    <td width="255">
    <input type="submit" value="Upload" name="submit">
    </td>
    </tr>
    </table>
    </form>
    <?
    }
    ?>


    any ideas?

    Thanks,
    MIKE
    Last edited by myqhenry; February 27th, 2002 at 01:10 AM.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2001
    Location
    NYC
    Posts
    52
    Rep Power
    14
    ok,
    i changed

    $server_dir="tmp/";

    to

    $server_dir="www/".$userfile_name;

    and now it works.

    WHY?


    thanks,
    MIKE

IMN logo majestic logo threadwatch logo seochat tools logo