Forum Moderators: coopster
so i have a bunch of folders and one(1) file in each of them called index.html all set to 'nobody'.. im trying to delete/chmod them via php or ftp but i just cant at the moment..
i tried to chown and its not working since im on a shared hosting(linux, php4.4.2).. the script:
------------------------------------------------------------------
$file_name= "index.html";
$path = "***/public_html/testtt/" . $file_name ;$user_name = '***';
chown($path, $user_name);
------------------------------------------------------------------
again refering to the last post in the link above, i tried it it did not give me any error but the files remained as it was, no changes.. here is the script:
------------------------------------------------------------------
$ftp_server="***";
$ftp_user = "**";
$ftp_password = "**";// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user, $ftp_password);
$mode = 0755;
$filename = "testtt/index.html";
if (!function_exists('ftp_chmod')) {
function ftp_chmod($conn_id, $mode, $filename)
{
return ftp_site($conn_id, sprintf('CHMOD %o %s', $mode, $filename));
}
}
// close the connection
ftp_close($conn_id);
------------------------------------------------------------------
if i cant chmod it i would really just want those folders and file removed but the problem is how? thanks in advance!
the issue I usually have is that whoever creates them is the only one that can delete them, barring setting permissions to 777 which we try to avoid.
if php creates the dir then it should be able to delete it, if you create via ftp then both should be able to delete, though this is not always the case.
i tried unlink but im only able to delete the index.html in those folders but not the folder itself.. then i added on ftp_rmdir to delete the folder.. and it worked :)
heres the code perhaps might be useful to someone, peace
<?php
$ftp_server="***";
$ftp_user = "***";
$ftp_password = "***";// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user, $ftp_password);
unlink('***/public_html/folder_name/index.html');
$filename = '/public_html/folder_name/';
if (ftp_rmdir($conn_id, $filename)) {
echo "Successfully deleted $dir\n";
} else {
echo "There was a problem while deleting $dir\n";
}
// close the connection
ftp_close($conn_id);
?>