FTP PHP Doesnt Overwrite Existing File

Discussion in 'PHP' started by NITRO23456, Oct 16, 2013.

  1. #1
    I want the following script to overwrite the original file automatically if the file name is exactly the same, what do I need to change?

    
    <?php
    
    $ftp_server = "ftp.xxxxxx.com";
    
    $ftp_username  = "xxxxxx";
    
    $ftp_password  =  "xxxxxx";
    
    //setup of connection
    
    $conn_id = ftp_connect($ftp_server) or die ("could not connect to service");
    
    //login
    
    if(@ftp_login($conn_id, $ftp_username, $ftp_password))
    
    {
    
    header( 'Location: http://www. xxxxxx .com' );
    
    }
    
    else {
    
    echo "could not connect";
    
    }
    
    // turn passive mode on
    
    ftp_pasv($conn_id, true);
    
    
    $file = $_FILES["uploadedfile"]["name"];
    
    $remote_file_path = "/xxxxxx/xxxxx/".$file;
    
    ftp_put($conn_id, $remote_file_path, $_FILES["uploadedfile"]["tmp_name"], FTP_BINARY);
    
    ftp_close($conn_id);
    
    ?>
    
    Code (markup):

     
    NITRO23456, Oct 16, 2013 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    ftp_put() usually overwrites existing files. Perhaps make sure the file permissions are right?
     
    nico_swd, Oct 16, 2013 IP
  3. NITRO23456

    NITRO23456 Well-Known Member

    Messages:
    516
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #3
    as in CHMOD?
     
    NITRO23456, Oct 16, 2013 IP
  4. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #4
    login to shell then

     
    bartolay13, Oct 18, 2013 IP