osozos
112
4
Laravel

Unable to write to directory while populating

Posted 1 month ago by osozos

InvalidArgumentException : Cannot write to directory "/var/www/html/market/storage/app\public\products"

I did php artisan migrate and it was okay and then I tried to populate to check if I got everything right within my site but after php artisan db:seed this error is returned.

Full error displayed:

Creating categories...
Creating products...

   InvalidArgumentException  : Cannot write to directory "/var/www/html/market/storage/app\public\products"

  at /var/www/html/market/vendor/fzaninotto/faker/src/Faker/Provider/Image.php:69
    65|     {
    66|         $dir = is_null($dir) ? sys_get_temp_dir() : $dir; // GNU/Linux / OS X / Windows compatible
    67|         // Validate directory path
    68|         if (!is_dir($dir) || !is_writable($dir)) {
  > 69|             throw new \InvalidArgumentException(sprintf('Cannot write to directory "%s"', $dir));
    70|         }
    71|
    72|         // Generate a random filename. Use the server address so that a file
    73|         // generated at the same time on a different server won't have a collision.

  Exception trace:

  1   Faker\Provider\Image::image("/var/www/html/market/storage/app\public\products")
      /var/www/html/market/vendor/fzaninotto/faker/src/Faker/Generator.php:222

  2   call_user_func_array()
      /var/www/html/market/vendor/fzaninotto/faker/src/Faker/Generator.php:222

Faker/Provider/Image.php:

    public static function image($dir = null, $width = 640, $height = 480, $category = null, $fullPath = true, $randomize = true, $word = null)
    {
        $dir = is_null($dir) ? sys_get_temp_dir() : $dir; // GNU/Linux / OS X / Windows compatible
        // Validate directory path
        if (!is_dir($dir) || !is_writable($dir)) {
            throw new \InvalidArgumentException(sprintf('Cannot write to directory "%s"', $dir));
        }

I've tried:

sudo chown -R www-data:www-data /var/www/html/market/public
sudo chmod 755 /var/www/html
sudo chmod -R 755 /var/www/html/market/bootstrap/cache
sudo chmod -R 755 /var/www/html/market/storage
sudo mkdir -p /var/www/html/market/storage/public/products
sudo chgrp -R www-data storage/public/products
sudo chmod -R ug+rwx storage/public/products
php artisan storage:link

Stuck in this for almost a week now. Thanks in advance.

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.