Jump to content

[SOLVED] Can not create directories with mkdir?


nahydy

Recommended Posts

No it don't show any error, and there is no directorie created into the /var/www. I created a directorie test into the /var/www and change owner to www-data. But when i tried to make this

mkdir('/var/www/test/toto',0777,true);

 

there is no toto into my directorie. I don't see where the problem is.

Try this it works this end......


<?php

    
    $dir_name='redarrow/';

    $sub_directory='redarrow_files';

    $create_dir=@mkdir("$dir_name");
   
    @chmod('0777'.$create_dir);
    
    $create_dir2=@mkdir("$dir_name"."$sub_directory");
    	 
    @chmod('0777'.$create_dir2);
      
    echo "diretory $dir_name $sub_directory made!";

exit;
      
?>

 

Here another interesting one for u.


<?php

    
    $dir_name='redarrow/';

    $create_dir=@mkdir("$dir_name");
   
    @chmod('0777'.$create_dir);
   
    $f=array("a","b","c");
    
    foreach($f as $sub_directory){
     
    $create_dir2=@mkdir("$dir_name"."$sub_directory");
    	 
    }
    
    @chmod('0777'.$create_dir2);
      
    exit;
    
    
?>

<?php

// user name would use user id .......    
    $d=array('redarrow','john','paul','sharon','lisa');

    foreach($d as $dir_name){
    	
    $create_dir=@mkdir("$dir_name");
   
    @chmod('0777'.$create_dir);
   
//inside user name
    $f=array("photo_album","fav_pictures","drawings","personal_pictures","dirty_pictures");
    
    foreach($f as $sub_directory){
     
    $create_dir2=@mkdir("$dir_name/"."$sub_directory");
    	 
    }
     } 
    
     @chmod('0777'.$create_dir2);
      
    exit;
    
    
?>

I tried the two methods but none of them created my directories. But i tried this and worked well:

shell_exec('mkdir /var/www/test/toto');

 

I have a question: why using @ before chmod and mkdir?

And thank you for helping me. :)

It supresses any errors that come up.

 

@ << All it does is suppress the error from the php.ini engine.

 

in other words dont want to see the error, some functions like mkdir and others give errors

but it not a coding error just the way it is.......

 

Dont this for fun for you and me m8.


<?php

    
    $d=array('redarrow','john','paul','sharon','lisa');

    foreach($d as $dir_name){
    	
    $create_dir=@mkdir("$dir_name");
   
    @chmod('0777'.$create_dir);
   
    $f=array("photo_album","fav_pictures","drawings","personal_pictures","dirty_pictures");
    
    foreach($f as $sub_directory){
     
    $create_dir2=@mkdir("$dir_name/"."$sub_directory");
    	 
    }
     } 
    
     @chmod('0777'.$create_dir2);
     
      
     foreach($d as $directorys){
    
     $path = $directorys;
     
     
     
     $dir_handle = @opendir($path) or die("Unable to open $path");

    while ($file = readdir($dir_handle)) {

    
    	if($file == "." || $file == ".." || $file == "index.php" )

    	continue;

        echo "Inside directory: $directorys has this file <a href=\"$file\">$file</a><br /> <br><br>";



    }
     }
    closedir($dir_handle);

    
    
    
?>

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.