fput + no such file or directory

Discussion in 'PHP' started by vetrivel, Jul 9, 2009.

  1. #1
    
    $file = "test.txt";
    
    $ftp_server = "servename ";
    $ftp_user_name = "username";
    $ftp_user_pass = "password";
    $destination_file = $file;
    
    
    $source_file = "DOCUMENT_ROOT".$file;
    
    
    
    // set up the FTP connection
    $conn_id = ftp_connect("$ftp_server");
    
    $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
    
    if ((!$conn_id) || (!$login_result)) {
            echo "FTP connection has failed!";
            echo "Attempted to connect to $ftp_server for user $ftp_user_name";
            
        } else {
            echo "Connected to $ftp_server, for user $ftp_user_name";
        }
     
       
      echo ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
    // upload the file
    $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
    
    // check upload status
    if (!$upload) {
            echo "FTP upload has failed!";
        } else {
            echo "Uploaded $source_file to $ftp_server as $destination_file";
        }
     
    // close the FTP stream
    ftp_close($conn_id);
    PHP:
    When i run this script i am getting the error message as "NO SUCH FILE OR DIRECTORY ".

    Why i am getting this error ?
    Please advice me.
    Thanks in advance.
     
    vetrivel, Jul 9, 2009 IP
  2. samyak

    samyak Active Member

    Messages:
    280
    Likes Received:
    7
    Best Answers:
    4
    Trophy Points:
    90
    #2
    you haven't set $destination_file
     
    samyak, Jul 9, 2009 IP
  3. anthonywebs

    anthonywebs Banned

    Messages:
    657
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #3
    you didnt put anything in the $destination_file
     
    anthonywebs, Jul 9, 2009 IP
  4. vetrivel

    vetrivel Peon

    Messages:
    147
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Even after provided the abosulte path of the destination server .I am getting the same Message.
     
    vetrivel, Jul 9, 2009 IP