1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.
  2. Better Analytics for WordPress Get It Free

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,149
    Likes Received:
    340
    Best Answers:
    18
    Trophy Points:
    325
    #2
    ftp_put() usually overwrites existing files. Perhaps make sure the file permissions are right?
     
    nico_swd, Oct 16, 2013 IP
  3. NITRO23456

    NITRO23456 Active Member

    Messages:
    483
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    60
    #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