Laravel's Storage::Files not finding my files
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
add a comment |
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
add a comment |
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
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
php laravel controller storage
edited Nov 19 '18 at 14:52
Evilbleezard
asked Nov 19 '18 at 14:43
EvilbleezardEvilbleezard
3210
3210
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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
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
add a comment |
Use public_path($directory); for this
Tryed it and not working neither; count are still on 0
– Evilbleezard
Nov 21 '18 at 7:59
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
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
add a comment |
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
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
add a comment |
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
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
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
add a comment |
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
add a comment |
Use public_path($directory); for this
Tryed it and not working neither; count are still on 0
– Evilbleezard
Nov 21 '18 at 7:59
add a comment |
Use public_path($directory); for this
Tryed it and not working neither; count are still on 0
– Evilbleezard
Nov 21 '18 at 7:59
add a comment |
Use public_path($directory); for this
Use public_path($directory); for this
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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