Jump to content

[SOLVED] mkdir


daveoffy

Recommended Posts

Hello, I am trying to make it so it will make a folder with the username.

 

I have this and it works

mkdir('../sites/test', 0777);

 

but when I do this it doesn't

mkdir('../sites/'.$username, 0777);

 

Try this:

mkdir('../sites/{$username}', 0777);

Link to comment
https://forums.phpfreaks.com/topic/147333-solved-mkdir/#findComment-773360
Share on other sites

//my response while you responded... :-P

 

<?php
//i think this is inside literal so you might get a dir named..  .$username ..literally
mkdir('../sites/.$username', 0777);

 

are you trying to do any error reporting or anything...

try this....

<?php

function handleError() {
    trigger_error('MY ERROR');

    /** usage sample
        @handleError();
        echo $php_errormsg;
    */
}

// detect slash/backslash nomenclature dirname
$path = dirname( __FILE__ );
$slash = '/'; strpos( $path, $slash ) ? '' : $slash = '\\';
define( 'BASE_DIR', $path . $slash );

$folder  = '../sites/'.$username;               // folder name
$dirPath = BASE_DIR . $folder;   // folder path

// print results
echo $slash;
echo '<hr>';

$rs = @mkdir( $dirPath, '0777' );
@handleError();
if( $rs )
{

    // print success information
    echo 'was done!';
    echo '<br>folder: <a href="' . $folder . '">' . $folder . '</a>';
    echo '<br>dirPath: ' . $dirPath;

}else{
    
    // print error information
    echo 'an error was occurred. Attempting create folder';
    echo '<br>dirPath: ' . $dirPath;
    echo '<br>php_errormsg: ' . $php_errormsg;

}
?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/147333-solved-mkdir/#findComment-773368
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.