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.

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?

    Code (Text):
    1.  
    2. <?php
    3.  
    4. $ftp_server = "ftp.xxxxxx.com";
    5.  
    6. $ftp_username  = "xxxxxx";
    7.  
    8. $ftp_password  =  "xxxxxx";
    9.  
    10. //setup of connection
    11.  
    12. $conn_id = ftp_connect($ftp_server) or die ("could not connect to service");
    13.  
    14. //login
    15.  
    16. if(@ftp_login($conn_id, $ftp_username, $ftp_password))
    17.  
    18. {
    19.  
    20. header( 'Location: http://www. xxxxxx .com' );
    21.  
    22. }
    23.  
    24. else {
    25.  
    26. echo "could not connect";
    27.  
    28. }
    29.  
    30. // turn passive mode on
    31.  
    32. ftp_pasv($conn_id, true);
    33.  
    34.  
    35. $file = $_FILES["uploadedfile"]["name"];
    36.  
    37. $remote_file_path = "/xxxxxx/xxxxx/".$file;
    38.  
    39. ftp_put($conn_id, $remote_file_path, $_FILES["uploadedfile"]["tmp_name"], FTP_BINARY);
    40.  
    41. ftp_close($conn_id);
    42.  
    43. ?>
    44.  

    NITRO23456, Oct 16, 2013 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,119
    Likes Received:
    331
    Best Answers:
    17
    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:
    479
    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