PDA

View Full Version : Ownership/Permission issues


Useless
2006-07-20, 05:45 PM
Is there a PHP function that allows one to create directories with a script that doesn't make them owned by the server? Or, is there a function that can successfuly delete directories that have been created by a PHP script instead of giving me the "Fuck You - You Suck/Don't Have Permission" error like rmdir?

HC-Majick
2006-07-20, 06:27 PM
edit: just noticed the rmdir part... |banghead|

<?php
// Sets All Permissions
chmod("mydirectory", 0777);
?>
before your rmdir fuction??

Beaver Bob
2006-07-25, 04:24 AM
useless, I've always found it easier to have PHP use FTP. I've never had much luck any other way. If FTP extensions aren't installed with the version of PHP on your server, have your system admin do that first.

This function can be used to make a directory, the values you need to replace in this are $server, $user, and $pass. The first argument needs to be the absolute path of where you want to create your directory, the second is the name of the new directory.


// create directory through FTP connection
function FtpMkdir($path, $newDir) {

$server='255.255.255.255'; // ftp server
$connection = ftp_connect($server); // connection

// login to ftp server
$user = "USERNAME";
$pass = "PASSWORD";
$result = ftp_login($connection, $user, $pass);

// check if connection was made
if ((!$connection) || (!$result)) {
return false;
exit();
} else {
ftp_chdir($connection, $path); // go to destination dir
if(ftp_mkdir($connection,$newDir)) { // create directory
return $newDir;
} else {
return false;
}
ftp_close($connection); // close connection
}

}

Useless
2006-07-25, 12:02 PM
Thank you Beaver Bob. I'll give that try. Now all I have to do is remember what I was trying to do when I asked the question. ;)

Beaver Bob
2006-07-25, 10:31 PM
hope it helps you out :) The reason for using FTP is so the directories you create will belong to you and you should have no problems removing them or modifying stuff.