Laravel GLOB public path

In Laravel I want to get all images from a dir, I just have a problem getting the path to the public folder.

$images = []; foreach(File::glob('/public/img/uploads/*.*') as $filename) { $images[] = $filename; }

If I use this function it returns nothing, I also tried using public_path() but that returns the full path including my F:// dir.


I just have a problem getting the path to the public folder. I also tried using public_path() but that returns the full path including my F:// dir.

It does it as manual reads:

Get the fully qualified path to the root of the application install.

Get the fully qualified path to the config directory.

Get the fully qualified path to the public directory.

Get the fully qualified path to the storage directory.


I doubt your public directory is in your root folder and this is what your absolute path you used points to, so use what public_path() returns - it rather is nothing to bother it is full qualified path.

Category:laravel Time:2019-01-09 Views:4
Tags: path glob laravel

Related post

  • CakePHP - How to get public path to application root 2011-07-21

    I'm looking for a constant or variable that will provide a public path to my application root. I have got so far as FULL_BASE_URL which gives me but I have the added problem of my application being in a sub directory (e.g. http

  • laravel uploading pic path showing zero 2013-12-14

    WHen uploading, all data is inserted in table except pic_path column contains 0. Am i doing wrong when processing file uploaded: This is the controller: if(Session::has('userLogged')) { if($_POST) { $file; if (Input::hasFile('pic')) { $file = Input::

  • How can I forward a public path to another Catalyst controller? 2010-01-02

    Let say the public URL /faq is linked to the private path /faq/index in my Catalyst application: package MyApp::Controller:FAQ; sub index :Path { [....] How can I do a forward to /faq from another controller, that is how can I know that the action fo

  • Zend Framework: get public path, get application url 2012-02-22

    Are there some proper Zend methods for: a) receiving path to /public directory b) receiving application url Actually I'm using methods defined in Controller, but it feel right to use ready methods if they exits. protected function _getApplicationUrl(

  • how get the exact public path where a rails app lives 2011-01-14

    Lets assume my RoR app lives at In a view file, how can I get that path? --------------Solutions------------- To get full url of the current page you can use current_url = request.request_uri This will ret

  • How to prevent access to a whitelist of IPS, exclude public paths allow for CDN access? 2011-08-24

    I have a staging server that I want to have a whitelist of IPs for. Problem is, the staging server uses an origin server that needs to hit the staging server. It's Amazon's CloudFront which has no static IPs we can use. Anyone have any ideas on how I

  • Laravel 5 cacheTags path 2015-03-13

    What is the use clause needed for cacheTags? I have: $categories = FinanceTransactionCategory::select('id') ->cacheTags(['cell-editors', 'categories']) ->remember(60)->get(); $jsConfig['filters'] = [ 'category' => $categories ]; But it's

  • using glob to return a list of folders in a given directory (without paths) 2009-12-15

    The function below returns all folders in a given directory down to multiple levels. I only need one level depth though, just folders in the target directory, no subfolders. Also the function returns the full path to the folder, I only want the folde

  • Laravel routes, index.php and relative paths 2014-07-06

    I have a problem with Laravel and its routes, amongst other things. I'm restructuring a website that I put online earlier this year, and I decided to use views directly instead of calling the backend data through AJAX. Since I'll be deploying to shar

  • Getting absolute path to the file inside the public folder in Rails 2010-07-24

    What is the best way to get absolute path to the file inside the public folder in controller? Is there a predefined Rails variable that holds absolute path to the public folder? Currently I'm using File.expand_path('../../../public', __FILE__), but I

  • Dir.glob doesn't work on site hosted by site5? 2008-12-16

    I have uploaded some files to a directory under public and I try to access them using Dir.glob. But I get no results back. The Dir.glob works fine on dev server (mongrel) and also works fine when using script/console on the site installed on site5 is

  • help with glob pattern 2010-01-18

    It would be nice if someone could give me a regexp pattern for glob for getting below filenames: 1.jpg // this file 1_thumb.jpg 2.png // this file 2_thumb.png etc... returning the files without "_thumb". I have this pattern: $numericalFiles = glob("$

  • Laravel FrozenNode Administrator run in maintenance mode 2013-07-19

    My question is: How can I leave the Frozennode administrator runs normaly on Laravel Maintenance Mode? This is what I got in global.php App::down(function() { return Response::view('maintenance', array(), 503); }); Thanks! --------------Solutions----

  • How to setup laravel framework in wampserver properly? 2014-01-07

    I am studying laravel now. But I am having a difficulty in installing the framework in my wampserver. I followed this instruction but I am getting an error. Via Download Once Composer is installed, download the latest version of the Laravel framework

  • laravel 4 - route makes javascript impossible to load from view 2014-09-18

    my localhost uses a laravel route to open my view, which works: http://localhost/view/stock/equipment Laravel 4 route which returns my view: Route::get('view/stock/equipment', array('uses'=>'App\Controllers\Stock\[email protected]')); m

  • scons: making glob play nice with a build directory 2009-09-23

    I would like to build all .c files in a subdirectory. I figured I would do something like this: src/foo/SConscript contains: import glob; here = Dir('.'); sourcefiles_raw = glob.glob(here.path+'/*.c'); print(sourcefiles_raw); # print them for debuggi

  • Formula for the max number of paths through a grid? 2010-01-03

    Given a grid of open spots, and a certain number of tiles to place in those spots, what function f(openSpots, tilesToPlace) will give you the number of continuous paths you can form? Continuous paths are placements of the tiles such that each tile sh

  • Use a Glob() to find files recursively in Python? 2010-02-02

    This is what I have: Glob(os.path.join('src','*.c')) but I want to search the subfolders of src. Something like this would work: Glob(os.path.join('src','*.c')) Glob(os.path.join('src','*','*.c')) Glob(os.path.join('src','*','*','*.c')) Glob(os.path.

  • Python: How to Access Linux Paths 2010-02-22

    Using Python, how does one parse/access files with Linux-specific features, like "~/.mozilla/firefox/*.default"? I've tried this, but it doesn't work. Thanks --------------Solutions------------- This import glob, os glob.glob(os.path.expanduser('~/.m

  • Reading Japanese filenames in windows, using Python and glob not working 2010-06-20

    I just setup PortablePython on my system, so I can run python scripts from PHP and I got some very basic code (Below) to list all the files in a directory, however it doesn't work with Japanese filenames. It works fine with English filenames, but it

Copyright (C), All Rights Reserved.

processed in 0.626 (s). 13 q(s)