samedi 30 septembre 2017

Laravel make directory fails with storage_path

Am using faker an i would like to generate images and save them but am getting an error

mkdir(): No such file or directory

So i have

$factory->define(App\User::class, function (Faker $faker) {
$filepath = storage_path('images/fakerusr/'); //this fails
 if(!File::exists($filepath)){
     File::makeDirectory($filepath);  
 };
return [
    'profile_pic' => $faker->image($filepath,400,300)

];

});

BUt when i use

$filepath = public_path('images/fakerusr/'); //this works

But the path saved in the db starts from ./var/www... but i would like the path from images in the public folder.

I have added both read and write permissions to public folder

sudo chmod a+rw -R /var/www.../public

How do i go about this.



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

Aucun commentaire:

Enregistrer un commentaire