Skip to content

Instantly share code, notes, and snippets.

@ctf0
Last active February 7, 2018 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctf0/9fa6013954654384052d2e2e809b9bf6 to your computer and use it in GitHub Desktop.
Save ctf0/9fa6013954654384052d2e2e809b9bf6 to your computer and use it in GitHub Desktop.
<?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