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.

Link to comment
Share on other sites

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;
      
?>

Link to comment
Share on other sites

 

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;
    
    
?>

Link to comment
Share on other sites

<?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;
    
    
?>

Link to comment
Share on other sites

 

@ << 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);

    
    
    
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.