src/help/demo/ToolsController.php
public function browseFilesystem($path = '')
    {
        // helpers
        function getBreadcrumbs($base, $path)
        {
            $paths  = ['/' => $base];
            $path   = trim($path, '/');
            if ($path !== '')
            {
                $segments   = explode('/', $path);
                $current    = '/';
	            foreach($segments as $segment)
	            {
	                $current .= $segment . '/';
	                $paths[$current] = $segment;
	            }
            }
            return $paths;
        }

	    // paths
	    $path       = str_replace('../', '', $path);
	    $path       = '/' . trim(preg_replace('%[\\/]+%', '/', $path), '/');
        $realpath   = realpath(base_path($path));
	    $base       = pathinfo(base_path())['basename'];

        // found
        if($realpath)
        {
            try
            {
                $objects        = array_diff(scandir($realpath), ['.','..']);
                $breadcrumbs    = getBreadcrumbs($base, $path);
                $folders        = array_filter($objects, function($f) use ($realpath) { return is_dir($realpath . '/' . $f); });
                $files          = array_filter($objects, function($f) use ($realpath) { return is_file($realpath . '/' . $f); });
                $path           = rtrim($path, '/') . '/';
                $parent         = $path !== '/' ? preg_replace('%[^/]+/$%', '', $path) : '/';

                return view('sketchpad::help/tools/folder', compact('parent', 'path', 'folders', 'files', 'breadcrumbs'));
            }
            catch(\Exception $e)
            {
                return "Unable to read folder '$path'";
            }
        }

        // not found
        return "Path '$path' not found";
	}
public function browseFilesystem($path = '')
    {
        // helpers
        function getBreadcrumbs($base, $path)
        {
            $paths  = ['/' => $base];
            $path   = trim($path, '/');
            if ($path !== '')
            {
                $segments   = explode('/', $path);
                $current    = '/';
	            foreach($segments as $segment)
	            {
	                $current .= $segment . '/';
	                $paths[$current] = $segment;
	            }
            }
            return $paths;
        }

	    // paths
	    $path       = str_replace('../', '', $path);
	    $path       = '/' . trim(preg_replace('%[\\/]+%', '/', $path), '/');
        $realpath   = realpath(base_path($path));
	    $base       = pathinfo(base_path())['basename'];

        // found
        if($realpath)
        {
            try
            {
                $objects        = array_diff(scandir($realpath), ['.','..']);
                $breadcrumbs    = getBreadcrumbs($base, $path);
                $folders        = array_filter($objects, function($f) use ($realpath) { return is_dir($realpath . '/' . $f); });
                $files          = array_filter($objects, function($f) use ($realpath) { return is_file($realpath . '/' . $f); });
                $path           = rtrim($path, '/') . '/';
                $parent         = $path !== '/' ? preg_replace('%[^/]+/$%', '', $path) : '/';

                return view('sketchpad::help/tools/folder', compact('parent', 'path', 'folders', 'files', 'breadcrumbs'));
            }
            catch(\Exception $e)
            {
                return "Unable to read folder '$path'";
            }
        }

        // not found
        return "Path '$path' not found";
	}
public function browseFilesystem ( $ path = '' ) { // helpers function getBreadcrumbs ( $ base , $ path ) { $ paths = [ '/' => $ base ] ; $ path = trim ( $ path , '/' ) ; if ( $ path !== '' ) { $ segments = explode ( '/' , $ path ) ; $ current = '/' ; foreach ( $ segments as $ segment ) { $ current .= $ segment . '/' ; $ paths [ $ current ] = $ segment ; } } return $ paths ; } // paths $ path = str_replace ( '../' , '' , $ path ) ; $ path = '/' . trim ( preg_replace ( '%[\\/]+%' , '/' , $ path ) , '/' ) ; $ realpath = realpath ( base_path ( $ path ) ) ; $ base = pathinfo ( base_path ( ) ) [ 'basename' ] ; // found if ( $ realpath ) { try { $ objects = array_diff ( scandir ( $ realpath ) , [ '.' , '..' ] ) ; $ breadcrumbs = getBreadcrumbs ( $ base , $ path ) ; $ folders = array_filter ( $ objects , function ( $ f ) use ( $ realpath ) { return is_dir ( $ realpath . '/' . $ f ) ; } ) ; $ files = array_filter ( $ objects , function ( $ f ) use ( $ realpath ) { return is_file ( $ realpath . '/' . $ f ) ; } ) ; $ path = rtrim ( $ path , '/' ) . '/' ; $ parent = $ path !== '/' ? preg_replace ( '%[^/]+/$%' , '' , $ path ) : '/' ; return view ( 'sketchpad::help/tools/folder' , compact ( 'parent' , 'path' , 'folders' , 'files' , 'breadcrumbs' ) ) ; } catch ( \ Exception $ e ) { return "Unable to read folder '$path'" ; } } // not found return "Path '$path' not found" ; }
Browse your local filesystem

@param string $path
@return View|string
Browse your local filesystem