PHP code example of dr10s / directory-tree

1. Go to this page and download the library: Download dr10s/directory-tree library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dr10s / directory-tree example snippets


 $directoryTree = new DirectoryTree('./Files');
 $fileHash = md5('file_name'.microtime());
 $fileExtension = 'txt';
 $directory = $directoryTree->addDirectoryForFile($fileHash, $fileExtension);
 
 file_put_contents(
     sprintf('%s/%s.%s', $directory, $fileHash, $fileExtension),
     ''
   );