ok, i was needing to know how to make directories ...
so found the php mkdir function...
but within the comments at:
http://us2.php.net/mkdir
he states:
Quote:
If you're on a shared *nix server, a directory created through mkdir() will not be assigned to you, but to the user that your host's server or php process is running under, usually 'nobody', 'apache' or 'httpd'.
In practice, this means that you can create directories, even add files to them, but you can't delete the directory or its contents nor change permissions.
|
so the person who made the comment said to use PHP's FTP API ..
which is:
PHP Code:
<?php
// create directory through FTP connection
function FtpMkdir($path, $newDir) {
$server='ftp.yourserver.com'; // ftp server
$connection = ftp_connect($server); // connection
// login to ftp server
$user = "me";
$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($conn_id); // close connection
}
}
?>
got that to work ... i can create directories as I please ....
but now, it creates directories I think to 755 (drwxr-xr-x)
but I need to be able to upload to those directories that I created with my php script ..
and im running into a bit of a snag ....
i am trying to use php's chmod function
PHP Code:
chmod("/home/whiteazn/public_html/test/New_Directory_Created_by_script", 0777);
but it gives me this error:
Quote:
|
Operation not permitted in /home/whiteazn/public_html/fbc/test/createdir.php on line 131
|
i find this (2nd post from the top):
http://www.christian-web-masters.com...=0&#entry50843
it says:
Quote:
I often get this error when PHP is running under nobody and the directory you are trying to chmod is owned by someone else.
The way around it that I can see is to:
1) Ask the user to chmod it instead (most scripts do this)
2) Create an FTP connection in your script to your own server and log in with the account details and then chmod via FTP in the script.
3) Use a perl script and hope that runs under the owner instead
|
i tried number 2:
PHP Code:
function ftpmkdir($path, $newDir)
{
$server="ftp.whiteazn.com"; // ftp server
$connection = ftp_connect($server); // connection
// login to ftp server
$user = "whiteazn";
$pass = "jjclrg00";
$result = ftp_login($connection, $user, $pass);
// check if connection was made
if ((!$connection) || (!$result))
{
return "Could not make a FTP connection";
exit();
}
else
{
if (!(ftp_chdir($connection, $path))) // go to destination dir
{
return "Could not change the directory";
}
if(ftp_mkdir($connection,$newDir)) // create directory
{
$cmoddir = "/home/whiteazn/public_html/test/" . $newDir;
chmod("$cmoddir", 0777);
return $newDir;
}
else
{
return "cant create directory";
}
ftp_close($connection); // close connection
}
}
and it still gives me the same error ...
so how can i chmod in php ??