How to create new folder in php?

i am trying to create a folder using php, i have used the mkdir command to make a folder, however i would like it to make a folder based on the username of the person who is currently logged in. so far i have
"
<html>
<title> Upload Form </title>
<body>
<?php
mkdir("c:/xampp/htdocs/user/", 0700);
?>
</body>
</html>
"

I would liek it to create a folder after (/user/) and use the username of the person logged in
"
session_register("myusername");
"
("myusername") as the new folders name, how do i do this?

NachoMahma7 years ago
.  Try:
$myusername = "NachoMahma";
   session_register("myusername");
   $myNewFolderPath = "c:/xampp/htdocs/user/" . $myusername;
   if ( mkdir($myNewFolderPath, 0700) ) {
      // folder created
   } else {
      // something went wrong
   }
.  You may have to use a $_SESSION variable instead of $myusername, but I'm not familiar with using sessions in PHP so I can't say for sure.
.  Since you didn't escape any chars in yopur mkdir string, I'm assuming none need to be escaped.
.
.  BTW, according to the PHP docs, "This function* has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged."


*session_register()
comsa42 (author)  NachoMahma7 years ago
with a little bit of tweaking, worked like a charm, exept for the fact the folder created mached your username :D lol
yugnats comsa424 years ago
Hi comsa42, could you post your solution please i'm working on something similar and am having trouble. Thanks!
magento15 years ago
Use the mkdir  function to make a new folder.
<?php mkdir("<folder name>"); ?>
Magento Developers