-
-
Save mustafat0k/f39d27f40f4a4c249418f8e239a8b604 to your computer and use it in GitHub Desktop.
Laravel file ovveride
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function get_dir(Request $request) | |
{ | |
$root = base_path() . DIRECTORY_SEPARATOR; | |
// "C:\Users\fizikci\Desktop\dev\la1\" | |
$postDir = rawurldecode(base_path($request->get('dir'))); | |
if (file_exists($postDir)) | |
{ | |
$files = scandir($postDir); | |
// dd($files); | |
$returnDir = substr($postDir, strlen($root)); | |
natcasesort($files); | |
if (count($files) > 2) | |
{ // The 2 accounts for . and .. | |
echo "<ul class='jqueryFileTree'>"; | |
foreach ($files as $file) | |
{ | |
$htmlRel = htmlentities($returnDir . $file); | |
$htmlName = htmlentities($file); | |
$ext = preg_replace('/^.*\./', '', $file); | |
if (file_exists($postDir . $file) && $file != '.' && $file != '..') | |
{ | |
if (is_dir($postDir . $file)) | |
{ | |
echo "<li class='directory collapsed'><a rel='" . $htmlRel . "/'>" . $htmlName . "</a></li>"; | |
} | |
else | |
{ | |
echo "<li class='file ext_{$ext}'><a rel='" . $htmlRel . "'>" . $htmlName . "</a></li>"; | |
} | |
} | |
} | |
echo "</ul>"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment