Laravel's Storage::Files not finding my files












0















i wanted to count how many images are in a storage directory but it seems that Storage::Files not finding any of them, i've stored 4 images in storageapppublicproperty*id_of_the_property* and i've already excuted php artisan storage:link and the link are working perfectly, at least at first glance.



Here is my configFilesSystems.php



'disks' => [

'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],

'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],

's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
],

],


And my controler :



public function show($id)
{

$show = ;
$directory = 'property/'.$id;
$files = Storage::Files($directory);
$count = count($files);

$show['count'] = $count;
$show['directory'] = $directory;

return $show;
}


But the the variable $show['count'] is displaying 0 when it should be 4 and the Storage::Files are not doing any thing since $show['directory'] are showing "property/1" and 1 is the id that i'm testing with. What am i missing?



i've tryed using :



$directory = Storage::url('property/'.$id);
/* Result "/storage/property/1" */
$directory = Storage::url('app/public/property/'.$id);
/* Result "/storage/app/public/property/1" */


or



$directory = Storage_path('property\'.$id);
/* Result "D:\xampp\htdocs\www\APP\storage\property\1" */
$directory = Storage_path('app/public/property/'.$id);
/* Result "D:\xampp\htdocs\www\APP\storage\app\public\property\1" */


but no success too, the count are still 0.



Thank you for the help.










share|improve this question





























    0















    i wanted to count how many images are in a storage directory but it seems that Storage::Files not finding any of them, i've stored 4 images in storageapppublicproperty*id_of_the_property* and i've already excuted php artisan storage:link and the link are working perfectly, at least at first glance.



    Here is my configFilesSystems.php



    'disks' => [

    'local' => [
    'driver' => 'local',
    'root' => storage_path('app'),
    ],

    'public' => [
    'driver' => 'local',
    'root' => storage_path('app/public'),
    'url' => env('APP_URL').'/storage',
    'visibility' => 'public',
    ],

    's3' => [
    'driver' => 's3',
    'key' => env('AWS_ACCESS_KEY_ID'),
    'secret' => env('AWS_SECRET_ACCESS_KEY'),
    'region' => env('AWS_DEFAULT_REGION'),
    'bucket' => env('AWS_BUCKET'),
    'url' => env('AWS_URL'),
    ],

    ],


    And my controler :



    public function show($id)
    {

    $show = ;
    $directory = 'property/'.$id;
    $files = Storage::Files($directory);
    $count = count($files);

    $show['count'] = $count;
    $show['directory'] = $directory;

    return $show;
    }


    But the the variable $show['count'] is displaying 0 when it should be 4 and the Storage::Files are not doing any thing since $show['directory'] are showing "property/1" and 1 is the id that i'm testing with. What am i missing?



    i've tryed using :



    $directory = Storage::url('property/'.$id);
    /* Result "/storage/property/1" */
    $directory = Storage::url('app/public/property/'.$id);
    /* Result "/storage/app/public/property/1" */


    or



    $directory = Storage_path('property\'.$id);
    /* Result "D:\xampp\htdocs\www\APP\storage\property\1" */
    $directory = Storage_path('app/public/property/'.$id);
    /* Result "D:\xampp\htdocs\www\APP\storage\app\public\property\1" */


    but no success too, the count are still 0.



    Thank you for the help.










    share|improve this question



























      0












      0








      0








      i wanted to count how many images are in a storage directory but it seems that Storage::Files not finding any of them, i've stored 4 images in storageapppublicproperty*id_of_the_property* and i've already excuted php artisan storage:link and the link are working perfectly, at least at first glance.



      Here is my configFilesSystems.php



      'disks' => [

      'local' => [
      'driver' => 'local',
      'root' => storage_path('app'),
      ],

      'public' => [
      'driver' => 'local',
      'root' => storage_path('app/public'),
      'url' => env('APP_URL').'/storage',
      'visibility' => 'public',
      ],

      's3' => [
      'driver' => 's3',
      'key' => env('AWS_ACCESS_KEY_ID'),
      'secret' => env('AWS_SECRET_ACCESS_KEY'),
      'region' => env('AWS_DEFAULT_REGION'),
      'bucket' => env('AWS_BUCKET'),
      'url' => env('AWS_URL'),
      ],

      ],


      And my controler :



      public function show($id)
      {

      $show = ;
      $directory = 'property/'.$id;
      $files = Storage::Files($directory);
      $count = count($files);

      $show['count'] = $count;
      $show['directory'] = $directory;

      return $show;
      }


      But the the variable $show['count'] is displaying 0 when it should be 4 and the Storage::Files are not doing any thing since $show['directory'] are showing "property/1" and 1 is the id that i'm testing with. What am i missing?



      i've tryed using :



      $directory = Storage::url('property/'.$id);
      /* Result "/storage/property/1" */
      $directory = Storage::url('app/public/property/'.$id);
      /* Result "/storage/app/public/property/1" */


      or



      $directory = Storage_path('property\'.$id);
      /* Result "D:\xampp\htdocs\www\APP\storage\property\1" */
      $directory = Storage_path('app/public/property/'.$id);
      /* Result "D:\xampp\htdocs\www\APP\storage\app\public\property\1" */


      but no success too, the count are still 0.



      Thank you for the help.










      share|improve this question
















      i wanted to count how many images are in a storage directory but it seems that Storage::Files not finding any of them, i've stored 4 images in storageapppublicproperty*id_of_the_property* and i've already excuted php artisan storage:link and the link are working perfectly, at least at first glance.



      Here is my configFilesSystems.php



      'disks' => [

      'local' => [
      'driver' => 'local',
      'root' => storage_path('app'),
      ],

      'public' => [
      'driver' => 'local',
      'root' => storage_path('app/public'),
      'url' => env('APP_URL').'/storage',
      'visibility' => 'public',
      ],

      's3' => [
      'driver' => 's3',
      'key' => env('AWS_ACCESS_KEY_ID'),
      'secret' => env('AWS_SECRET_ACCESS_KEY'),
      'region' => env('AWS_DEFAULT_REGION'),
      'bucket' => env('AWS_BUCKET'),
      'url' => env('AWS_URL'),
      ],

      ],


      And my controler :



      public function show($id)
      {

      $show = ;
      $directory = 'property/'.$id;
      $files = Storage::Files($directory);
      $count = count($files);

      $show['count'] = $count;
      $show['directory'] = $directory;

      return $show;
      }


      But the the variable $show['count'] is displaying 0 when it should be 4 and the Storage::Files are not doing any thing since $show['directory'] are showing "property/1" and 1 is the id that i'm testing with. What am i missing?



      i've tryed using :



      $directory = Storage::url('property/'.$id);
      /* Result "/storage/property/1" */
      $directory = Storage::url('app/public/property/'.$id);
      /* Result "/storage/app/public/property/1" */


      or



      $directory = Storage_path('property\'.$id);
      /* Result "D:\xampp\htdocs\www\APP\storage\property\1" */
      $directory = Storage_path('app/public/property/'.$id);
      /* Result "D:\xampp\htdocs\www\APP\storage\app\public\property\1" */


      but no success too, the count are still 0.



      Thank you for the help.







      php laravel controller storage






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 19 '18 at 14:52







      Evilbleezard

















      asked Nov 19 '18 at 14:43









      EvilbleezardEvilbleezard

      3210




      3210
























          2 Answers
          2






          active

          oldest

          votes


















          0














          you can use File facade



          use IlluminateSupportFacadesFile;
          ...
          $images = File::allFiles(storage_path('app/public/property')); // this is recursive


          or



          $images = File::files(storage_path('app/public/property/'.$id)); // this is NOT recursive





          share|improve this answer
























          • Already tryed it with no success. actually it makes this error : "preg_match() expects parameter 2 to be string, array given "

            – Evilbleezard
            Nov 19 '18 at 15:54





















          0














          Use public_path($directory); for this






          share|improve this answer
























          • Tryed it and not working neither; count are still on 0

            – Evilbleezard
            Nov 21 '18 at 7:59











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53377016%2flaravels-storagefiles-not-finding-my-files%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          you can use File facade



          use IlluminateSupportFacadesFile;
          ...
          $images = File::allFiles(storage_path('app/public/property')); // this is recursive


          or



          $images = File::files(storage_path('app/public/property/'.$id)); // this is NOT recursive





          share|improve this answer
























          • Already tryed it with no success. actually it makes this error : "preg_match() expects parameter 2 to be string, array given "

            – Evilbleezard
            Nov 19 '18 at 15:54


















          0














          you can use File facade



          use IlluminateSupportFacadesFile;
          ...
          $images = File::allFiles(storage_path('app/public/property')); // this is recursive


          or



          $images = File::files(storage_path('app/public/property/'.$id)); // this is NOT recursive





          share|improve this answer
























          • Already tryed it with no success. actually it makes this error : "preg_match() expects parameter 2 to be string, array given "

            – Evilbleezard
            Nov 19 '18 at 15:54
















          0












          0








          0







          you can use File facade



          use IlluminateSupportFacadesFile;
          ...
          $images = File::allFiles(storage_path('app/public/property')); // this is recursive


          or



          $images = File::files(storage_path('app/public/property/'.$id)); // this is NOT recursive





          share|improve this answer













          you can use File facade



          use IlluminateSupportFacadesFile;
          ...
          $images = File::allFiles(storage_path('app/public/property')); // this is recursive


          or



          $images = File::files(storage_path('app/public/property/'.$id)); // this is NOT recursive






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 19 '18 at 15:48









          simonecoscisimonecosci

          81158




          81158













          • Already tryed it with no success. actually it makes this error : "preg_match() expects parameter 2 to be string, array given "

            – Evilbleezard
            Nov 19 '18 at 15:54





















          • Already tryed it with no success. actually it makes this error : "preg_match() expects parameter 2 to be string, array given "

            – Evilbleezard
            Nov 19 '18 at 15:54



















          Already tryed it with no success. actually it makes this error : "preg_match() expects parameter 2 to be string, array given "

          – Evilbleezard
          Nov 19 '18 at 15:54







          Already tryed it with no success. actually it makes this error : "preg_match() expects parameter 2 to be string, array given "

          – Evilbleezard
          Nov 19 '18 at 15:54















          0














          Use public_path($directory); for this






          share|improve this answer
























          • Tryed it and not working neither; count are still on 0

            – Evilbleezard
            Nov 21 '18 at 7:59
















          0














          Use public_path($directory); for this






          share|improve this answer
























          • Tryed it and not working neither; count are still on 0

            – Evilbleezard
            Nov 21 '18 at 7:59














          0












          0








          0







          Use public_path($directory); for this






          share|improve this answer













          Use public_path($directory); for this







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 21 '18 at 6:58









          shikhashikha

          524




          524













          • Tryed it and not working neither; count are still on 0

            – Evilbleezard
            Nov 21 '18 at 7:59



















          • Tryed it and not working neither; count are still on 0

            – Evilbleezard
            Nov 21 '18 at 7:59

















          Tryed it and not working neither; count are still on 0

          – Evilbleezard
          Nov 21 '18 at 7:59





          Tryed it and not working neither; count are still on 0

          – Evilbleezard
          Nov 21 '18 at 7:59


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53377016%2flaravels-storagefiles-not-finding-my-files%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to pass form data using jquery Ajax to insert data in database?

          National Museum of Racing and Hall of Fame

          Guess what letter conforming each word