PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Wed Jan 05, 2005 9:26 pm
i want to create a directory and then autmatically chmod to 0777. iv tried this
Code: Select all
<?php
$makedir = mkdir("users/$username", 0777);
?>
but that dont work? why?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Jan 05, 2005 9:31 pm
doesn't work.. how?
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Wed Jan 05, 2005 9:40 pm
thats what im askin! any sugestions to auto chmod a folder?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Jan 05, 2005 9:54 pm
no. I mean how is it not working. The directory didn't get created. Or the chmod is different than "expected"
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Wed Jan 05, 2005 10:23 pm
diffrent that expected the folders created but the chmod is so only the "owner" can write but i want everyone to be able to write!
rehfeld
Forum Regular
Posts: 741 Joined: Mon Oct 18, 2004 8:14 pm
Post
by rehfeld » Wed Jan 05, 2005 10:31 pm
if safemode is NOT on, try this
Code: Select all
$old = umask(0);
chmod("/some/dir", 0755);
umask($old);
if safemode is on, you cant do anything about it. its a limitation of safemode.
you could however use php's ftp functions to log in via ftp on the fly, and create the directory that way.
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Wed Jan 05, 2005 10:34 pm
safemode is on...how would u do the ftp thing?
rehfeld
Forum Regular
Posts: 741 Joined: Mon Oct 18, 2004 8:14 pm
Post
by rehfeld » Wed Jan 05, 2005 10:36 pm
http://www.php.net/ftp
i beleive someone actually posted a code sample of how to do it via ftp on the page for mkdir() though
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Wed Jan 05, 2005 11:30 pm
ok im trying to do it through the ftp but i keep getting
Warning: ftp_site(): example/example/: Operation not permitted
my code is
Code: Select all
<?php
$ftp_server = "ftp.example.com";
$ftp_user = "username";
$ftp_pass = "password";
$ftp_file = "path/to/dir/i/want/to/chmod0777";
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
ftp_site($conn_id, $ftp_file);
} else {
echo "Couldn't connect as $ftp_user";
}
// close the connection
ftp_close($conn_id);
?>
why is this "not permitted"??
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Jan 05, 2005 11:47 pm
you aren't sending a site command.. just a path.
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Thu Jan 06, 2005 12:02 am
sorry while deleting my personal info i deleted under $ftp_file somtin important that i do have in my code. $ftp_file actually looks like this
Code: Select all
<?php
$ftp_file = "chmod 0777 example/example/example";
?>
so i am actually sending the command. my bad. also this is the 1st time iv ever used ftp commands in php so i really dont know all what im doing. i tried ftp_chmod also with a slightly diffrent code but it gave me a error saying that ftp_chmod isnt even a command at all...why?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Jan 06, 2005 12:10 am
ftp_chmod is php5 only.
As for the failure.. it may require an absolute path to the directory (that path does exist right?)
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Thu Jan 06, 2005 12:14 am
ya the path does exist (that one took me like 15 minutes to figure out
)
as for the absolute path ill try that and post back
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Thu Jan 06, 2005 12:20 am
ok i tried
Code: Select all
<?php
ftp_site($conn_id, "CHMOD 0777 /folder/folder");
?>
but still same problem, but i dont think thats what u ment by direct path. elaborate on that because i dont get it
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Jan 06, 2005 12:40 am
that's an absolute path, however, I'm not sure that's an actual location on the server. Typical is something like /home/some_username/public_html/folder/folder
It's also possible that when your script logs into ftp, it's in a different folder than you may think. Try using [php_man]ftp_pwd()[/php_man] to see where you are starting in.