skip to Main Content

When i try to upload an image to my site, it stores in my storage folder, however, the symlink does not work so it doesnt save it in my public_html folder. I have tried using a custom symlink php file however it does not seem to do anything.

My symlinkcreate.php file

<?php
symlink('/home/jackdeaz/nscraft/storage/app/public', '/home/jackdeaz/public_html/storage');

my Filesystems.php file

'default' => env('FILESYSTEM_DRIVER', 'local'),

'disks' => [

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

        'public' => [
            'driver' => 'local',
            'root' => storage_path('app'),
            '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'),
        ],

    ],

This is how i upload an image

$request->file('image_url')->store('public/img/products');

Any help would be greatly appreciated!

2

Answers


  1. As explained by @MorganTouvereyQuilling here:

    1. Finding the web server username. If you are using Apache, use that command line:
    ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d  -f1
    
    1. Give permissions to web server (chmod, chown)

    Note: Doing a chmod of 666 or 777 can be sufficient but is unsecure. Giving 666 or 777 permissions will give access to “others”. It is better to be more precise and giver permissions to just you and Apache.

    Login or Signup to reply.
  2. This might definitely be a permissions issue. What permissions are being used by your (a) web server (e.g. nginx), PHP process manager (php-fpm). Ideally, these should be the same, and the director/ies they’re trying to store files in should have at least the same group permissions (e.g. 775).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search