Page 1 of 1

mkdir()

Posted: Wed Jul 17, 2002 4:37 am
by xexexexe
hi,
:!: i found a script that makes directories via html (script url: http://www.evilwalrus.com/viewcode.php?codeEx=1):

Code: Select all

<?php 

// START MAIN MAKEDIR FUNCTION 
if ($makedir ==  "MakeDir") &#123; 
   $content = "$direct"; 
   $dirmake = mkdir("$content", 0777); 

// DISPLAY LINK TO DIRECTORY AFTER MAKING IT 
PRINT   "<center> 
"; 
PRINT   "<a href="$content">CLICK HERE TO VIEW YOUR NEW DIRECTORY</a> 
"; 
PRINT   "</center> 
"; 

&#125; 

// MAIN FORM TO INPUT INFORMATION 
PRINT   "<form action="$PHP_SELF?action=direct"> 
"; 
PRINT   "<INPUT TYPE="text" NAME="direct" SIZE="15"> 
"; 
PRINT   "<br> 
"; 
PRINT   "<INPUT TYPE="submit" NAME="makedir" VALUE="MakeDir"> 
"; 
PRINT   "</FORM> 
"; 

?>
so when i want to use this script i get notice about ERROR (Warning: mkdir() failed (Permission denied) in /mnt/host-users/xexexexe/nothing.php3 on line 11).. What should i do? 8O

:idea: P.S. If u know some free php hosting, please post reply to this topic with hosting URL.

THNX!

Posted: Wed Jul 17, 2002 5:10 am
by Phirus
What kinda box are you running?

I gather its *nix - If so you must give the script/directorie(s) the correct permissions(chmod)

Phirus

Posted: Wed Jul 17, 2002 5:31 am
by twigletmac
If you're looking for hosting please post in the hosting forum where there is already a thread about free PHP hosts.

Mac

Posted: Wed Jul 17, 2002 7:24 am
by lc
Be certain that the directory inside which you make the new directory allows you to do so. Try to chmod a directory to 777 and then let the script make a new one inside that one.

That is basicly what phirus said ;)

Posted: Wed Jul 17, 2002 8:32 am
by haagen
You can try to give the full path to the place where you want to create the directory.

Eg.

Code: Select all

$dirpath = "/home/user/public_html/";
$newdir = "mynewdir";

mkdir("$dirpath$newdir", 0777);
Notice: The webserver is running as a diffrent user. Often www, http, www-data or nobody. This means that everyone has to have write permission to the parent directory ($dirpath). Change the permissions with "chmod 777 /home/user/public_html" (on the commandline).

I hope this helps.