Cytat
chmod("plik.txt", 0755);
wystetla blad
Warning: chmod() [
function.chmod]: Operation not permitted in ...
w komentarzach do funkcji chmod() jest na przykład takie coś:
If you get a warning like chmod(): Operation not permitted in ...
You can use the ftp_site() function to send a CHMOD command through.
<?php
$ftp_details['ftp_user_name'] = $row['username'];
$ftp_details['ftp_user_pass'] = $row['password'];
$ftp_details['ftp_root'] = '/public_html/';
$ftp_details['ftp_server'] = 'ftp'.$_SERVER['HTTP_HOST'];
function chmod_11oo10($path, $mod, $ftp_details)
{
// extract ftp details (array keys as variable names)
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// try to chmod $path directory
if (ftp_site($conn_id, 'CHMOD '.$mod.' '.$ftp_root.$path) !== false) {
$success=TRUE;
}
else {
$success=FALSE;
}
// close the connection
ftp_close($conn_id);
return $success;
}
?>
The key thing to remember is that the document root and the ftp root are not the same.
e.g. document root may be "/home/folder/public_html/"
but the ftp root might be "/public_html/"
Hope this helps someone. You might need this solution if you are on a shared server.