#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Posts
    5
    Rep Power
    0

    Unhappy ftp_put error - need help


    <?php
    $server="ftp.myserver.com";
    $user="myuser";
    $pass="mypass";

    // Connect & login to FTP server
    $ftp=ftp_connect($server) or die ("Problem with FTP server !");
    $conn=ftp_login($ftp,$user,$pass) or die ("Problem logining on to FTP server");

    $dir=ftp_pwd($ftp); // Stores current directory as $dir

    $file=$dir."/uploaded/datafile.txt"; // name of file we want to upload

    $localfile = "C:\testfile.txt";

    $upload=ftp_put($ftp,$file,$localfile,ftp_binary) or die ("Problem with upload");

    ?>

    RESULT : Warning: error opening
    C:\datafile.txt in ......script name

    Can anyone help ?

    If tried replacing C:\ with C:/ and C:// and lots of other combinations !

    Please Help

    v10
  2. #2
  3. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    792
    What OS, I know you are running a windoze machine, but is it NT,2000,XP? If so, does the web server have permissions to read the directory you are trying to access?

    Try moving the file you are trying to upload into the same directory that the script is located and see if that works.

    You might also want to ftp_chdir to the exact directory you are wanting to upload to.
    Last edited by Onslaught; June 12th, 2002 at 08:45 AM.
  4. #3
  5. 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
    Ok, first of all it should be $localfille="c:\\testfile.txt"; or $localfile='c:\testfile.txt'; and then, why do you upload .txt file in binary? Should be FTP_ASCII (note the capital letters, same with ftp_binary, should be capital)
    And you know I mean that.
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Posts
    5
    Rep Power
    0

    ahhhhh, still not working


    Ok, My Pc is running Win98SE and the server is UNIX.

    The script now reads as follows :

    <?php
    $server="ftp.server.com";
    $user="user";
    $pass="pass";

    // Connect & login to FTP server
    $ftp=ftp_connect($server) or die ("Problem with FTP server !");
    $conn=ftp_login($ftp,$user,$pass) or die ("Problem logining on to FTP server");

    $dir=ftp_pwd($ftp); // Stores current directory as $dir

    $file=$dir."/uploaded/datafile.txt"; // name of file we want to upload

    $localfile = 'C:\testfile.txt';

    $upload=ftp_put($ftp,$file,$localfile,FTP_ASCII) or die ("Problem with upload");

    ?>


    Still no Joy, Please help.... this is bugging me .....!

    Thanks for the help,

    V10
  8. #5
  9. 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
    "no joy" as in....
    And you know I mean that.
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Posts
    5
    Rep Power
    0
    No joy as in it's still not working.

    Can you help Mr. Capone ?

    I read somewhere else that ftp_put can only move files from one server to another, but I don't believe that, as that wouldn't be the normal use of ftp ?

    I've also seen this type of problem posted all over the place with similar type replies and no solution but I'm not a quitter.

    Surely this is possible, and someone out there knows a solution.

    It could be you.

    C'mon, put your thinking cap on

    V10
  12. #7
  13. 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
    >>I read somewhere else that ftp_put can only move files from one server
    >> to another, but I don't believe that, as that wouldn't be the normal use
    >> of ftp ?
    BS. What you've just describes is called fxp'ing, and it is widely popular in..uhm... not so legitimate purposes.

    What I meant is, what erros do you get? Try echoing each var before ftp_put and see if it says what you want.
    And you know I mean that.
  14. #8
  15. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Posts
    5
    Rep Power
    0
    Ok it now reads :

    <?php
    $server="ftp.server.com";
    $user="user";
    $pass="name";

    // Connect & login to FTP server
    $ftp=ftp_connect($server) or die ("Problem with FTP server !");
    $conn=ftp_login($ftp,$user,$pass) or die ("Problem logining on to FTP server");

    $dir=ftp_pwd($ftp); // Stores current directory as $dir

    $file=$dir."/ftp/datafile.txt"; // name of file we want to upload

    $localfile = 'C:\testfile.txt';

    echo "Connected to : $server as user : $user on Directory : $dir <br>";
    echo "The plan is to upload this file : $localfile to this directory : $file on the server <br>";

    $upload=ftp_put($ftp,$file,$localfile,FTP_ASCII) or die ("Problem with upload");

    ?>

    Result :

    Connected to : ftp.server.com as user : user on Directory : /
    The plan is to upload this file : C:\testfile.txt to this directory : /ftp/datafile.txt on the server

    Warning: error opening C:\testfile.txt in /home/ftp/ftpscript.php on line 19
    Problem with upload


    Appreciate the help al, what do you think ?

    V10
  16. #9
  17. 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
    What do I think? I think this is probably the longest thread about the dummest mistake You're on unix host, and you're trying to open file c:\testfile.txt on server's hdd. Sure enough, it gives errors, and you know why? There is no c:\testfile.txt, heck there is no c:\ there is / So you'll have to edit your path accordinally.
    And you know I mean that.
  18. #10
  19. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Posts
    5
    Rep Power
    0

    huh ?


    hmmm, I'm trying to upload from the users hdd to my unix server.

    The file C:\testfile.txt is on the same pc as the browser right ?

    I know there is no C drive on my server but the file isn't on my server, it's on a local pc with a browser running win98 that has a C drive.

    Am I seriously not with it today or what ?

    What way should I address the C drive of the users pc or can I ?

    Thanks for bearing with me


    V10
  20. #11
  21. 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
    PHP is server side langauge and therefore every file you request comes from server.
    >>What way should I address the C drive of the users pc or can I?
    You simply can't. At least not directly. What you could do though is to first make users upload file to server and then put it on ftp.
    And you know I mean that.

IMN logo majestic logo threadwatch logo seochat tools logo