Last active
February 7, 2018 20:39
-
-
Save ctf0/9fa6013954654384052d2e2e809b9bf6 to your computer and use it in GitHub Desktop.
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 | |
function getFilePath($disk, $filename) | |
{ | |
$config = config("filesystems.disks.$disk"); | |
$url = app('filesystem')->disk($disk)->url($filename); // get the file url | |
$root = array_get($config, 'root'); | |
// for other disks without root ex."cloud" | |
if (!$root){ | |
return preg_replace('/(.*\/\/.*?)\//', '', $url); // get the full path | |
} | |
$dir = str_replace(array_get($config, 'url'), '', $url); // remove the uri | |
return $root . $dir; // get the full path | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment