mkdir()

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

Post Reply
xexexexe
Forum Newbie
Posts: 3
Joined: Mon Jul 15, 2002 6:47 am

mkdir()

Post 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!
User avatar
Phirus
Forum Commoner
Posts: 37
Joined: Thu Apr 18, 2002 4:10 pm
Contact:

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
lc
Forum Contributor
Posts: 188
Joined: Tue Apr 23, 2002 6:45 pm
Location: Netherlands

Post 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 ;)
User avatar
haagen
Forum Commoner
Posts: 79
Joined: Thu Jul 11, 2002 3:57 pm
Location: Sweden, Lund

Post 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.
Post Reply