...

View Full Version : How to set permssion through ftp server



eshban
06-25-2005, 03:02 PM
Is it possible to set the permissions to file or directory throught ftp server like ftp.abc.com

if yes, then how

plz reply

delinear
06-25-2005, 06:30 PM
I do this all the time since chmod() doesn't work for me on my host. Here's the script I use:


<?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;
}

?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum