Thread: ftp

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

    Join Date
    Apr 2001
    Location
    NYC
    Posts
    52
    Rep Power
    14

    ftp


    hi,
    i have writen this block of code to connect, login and upload a file to an ftp:

    <?
    $conn = ftp_connect("localhost");
    $user = "";
    $pass = "";
    $result = ftp_login($conn, $user, $pass);
    if(!$result)
    {
    echo "cannot log you in";
    ftp_quit($conn);
    exit;
    }
    $upfile = "/Inetpub/ftproot/".$userfile_name;
    ftp_fput($conn, $upfile, FTP_BINARY)
    ?>

    , but when the script runs i get this error message:

    Warning: Unable to find ftpbuf 0 in c:\apache\htdocs\production\upload.php on line 11
    cannot log you in

    any ideas?
    thanks,
    MIKE
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Posts
    48
    Rep Power
    13

    Lightbulb Partial Idea


    It appears to be a configuration problem relating to PHP within Apache. Unfortunately, I'm just getting into this myself, so I don't know exactly where you go to fix that.
  4. #3
  5. phpkid ~~~~~~ :o)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Nov 2000
    Location
    NJ, USA
    Posts
    2,534
    Rep Power
    16

    Lightbulb ftp_fput syntax.


    hi u r mistaken about how ftp_fput works.
    this is from manual
    int ftp_fput (int ftp_stream, string remote_file, int fp, int mode)


    Returns TRUE on success, FALSE on error.

    ftp_fput() uploads the data from the file pointer fp until end of file. The results are stored in remote_file on the FTP server. The transfer mode specified must be either FTP_ASCII or FTP_BINARY
    u dont pass a file name to ftp_fput but a file pointer.
    so correct way is this.

    PHP Code:

    $fp 
    fopen($filename,'r');


    $remotefile "/upload/check.txt";
    $check ftp_fput($conn_ftp,$remotefile,$fp,FTP_BINARY);
    if(
    $check)
        print 
    "uploaded";
    else
        print 
    "Cant upload. 
    i hope it helps,
    jd
    Last edited by jdk; July 28th, 2001 at 08:31 AM.
    _____________________________
    d.k.jariwala (JD)
    ~ simple thought, simple act ~
    I blog @ http://jdk.phpkid.org
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2001
    Location
    NYC
    Posts
    52
    Rep Power
    14
    ok,
    I have another page that allows a user to browse the local files on his HD, now i want the user to be able to ftp his local file via ftp to my remote ftp server. This was what i was trying to do with that script.

    how would i go about that,

    MIKE
  8. #5
  9. phpkid ~~~~~~ :o)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Nov 2000
    Location
    NJ, USA
    Posts
    2,534
    Rep Power
    16

    Lightbulb ...


    hi,
    i think u would have to take 2 steps here.

    first let him upload the file.

    as u know it would be uploaded to temp directory.

    i hope u know how file uploading works in php.

    once it is uploaded do a fopen and get file pointer . now provide that to ftp_fput.

    once file is uploaded delete the uploaded file from temp directory.

    getting ??
    jd
    _____________________________
    d.k.jariwala (JD)
    ~ simple thought, simple act ~
    I blog @ http://jdk.phpkid.org
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2001
    Location
    NYC
    Posts
    52
    Rep Power
    14
    ok, why cant i bypass the temp directory.
    lemme explain what exactly this is for. I run a website for a publisher and am setting up a backend for our advertisers to upload and view their ads from our in-house file server. So the script will be executed from the remote webserver, not hosted by us, and will upload the file to our file server in our office. But i also have apache on our file server so i can have the backend hosted on our file server. Which is the better way to go? Now one major problem with this is that these files can exced 10MB, so i figured that if u used ftp the browser and php would not timeout, is this true? If not, should i use cURL or maybe something with sockets. I just got started with php and have a very week idea of c++ and c.


    MIKE
  12. #7
  13. phpkid ~~~~~~ :o)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Nov 2000
    Location
    NJ, USA
    Posts
    2,534
    Rep Power
    16

    Arrow hm..


    ok, why cant i bypass the temp directory.
    ...hm..i dont think it would be possible to upload file DIRECTLY from user to ftp account. anyways check out others views.

    lemme explain what exactly this is for. I run a website for a publisher and am setting up a backend for our advertisers to upload and view their ads from our in-house file server. So the script will be executed from the remote webserver, not hosted by us, and will upload the file to our file server in our office. But i also have apache on our file server so i can have the backend hosted on our file server. Which is the better way to go?
    fine..i got the whole idea.
    idea is good.
    i dont get u by what u mean to say which way to go ??
    i think u have only one ftp server right ? plz give more clarification.

    and in general, u should opt for ftp server, to which script would be able to communicate at MORE speed. using ur own server would be slow as u wont have as fast link as ISPs do.right ??

    Now one major problem with this is that these files can exced 10MB, so i figured that if u used ftp the browser and php would not timeout, is this true? If not, should i use cURL or maybe something with sockets. I just got started with php and have a very week idea of c++ and c.
    hm..i dont think u would be able to upload 10mb through a php file. certainly it would timeout if client doesnt have FAST connection. and let me emphasize FAST.

    btw i dont have any idea about cURL,plz let me know what it is.
    i think u would have to find some other way round,
    jd
    _____________________________
    d.k.jariwala (JD)
    ~ simple thought, simple act ~
    I blog @ http://jdk.phpkid.org

IMN logo majestic logo threadwatch logo seochat tools logo