samedi 30 janvier 2016

Laravel error. Failed to open dir: not implemented

I'm trying this script to render a gallery from all the pictures in a folder in a Laravel project. I got this error

ErrorException in ArmadiController.php line 32: opendir(http://ift.tt/1PGYtFj): failed to open dir: not implemented

this is the function in the controller that generates the error. How can i make it work or do something similar?

public function gallery()
    {
        $data = [];
        $folder_path = asset('images');
        $num_files = glob($folder_path . "*.{JPG,jpg,gif,png,bmp}", GLOB_BRACE);
        $folder = opendir($folder_path);
        if ($num_files > 0) {
            while (false !== ($file = readdir($folder))) {
                $file_path = $folder_path . $file;
                $extension = strtolower(pathinfo($file, PATHINFO_EXTENSION));
                if ($extension == 'jpg' || $extension == 'png' || $extension == 'gif' || $extension == 'bmp') {
                    $data[] = $file_path;
                }
            }
        } else {
            return "the folder was empty !";
        }
        closedir($folder);
        return $data;
    }



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1UxEn4N
via IFTTT

Aucun commentaire:

Enregistrer un commentaire