Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Apr 2005
    Location
    Lahore, Pakistan
    Posts
    150
    Thanks
    2
    Thanked 0 Times in 0 Posts

    How to set permssion through ftp server

    Is it possible to set the permissions to file or directory throught ftp server like ftp.abc.com

    if yes, then how

    plz reply

  • #2
    Regular Coder
    Join Date
    Feb 2005
    Location
    West Midlands, UK
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I do this all the time since chmod() doesn't work for me on my host. Here's the script I use:

    PHP Code:
    <?php
    function chmod_via_ftp($ftp_server$ftp_username$ftp_userpass$target$chmod) {
        
    // open connection
        
    $conn ftp_connect($ftp_server);
        
    $result ftp_login($conn$ftp_username$ftp_userpass);
        
        
    // set permission
        
    if (ftp_chmod($conn$chmod$target) !== false) {
            return 
    true;
        } else {
         return 
    false;
        }

        
    // close connection
        
    ftp_close($conn);
    }

    // set up variables
    $ftp_server 'server'// eg ftp.abc.com
    $ftp_username 'username';
    $ftp_userpass 'password';

    $chmod '0777'// whatever you want to chmod the target to
    $target '/path/to/dir/or/file';

    if(!
    chmod_via_ftp($ftp_server$ftp_username$ftp_userpass$target$chmod)) {
        echo 
    'Could not chmod ' $target;
    } else {
        echo 
    $target ' chmodded to ' $chmod;
    }

    ?>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •