mattnewark's avatar

Symbolic Link

Hello All,

I have created a symbolic link for my storage folder so that I am able to see the images that I upload in a view file. Locally I have done the link and it works a treat, I upload a image and it shows in the storage folder and then in the public folder so that I am able to access the images in the view. I have uploaded my changes to my remote server and the link seems to have stopped working, The upload works fine and I am getting the images in the storage folder and in the DB but when I go to the public folder they are not showing.

What am I doing wrong and how can I rectify the issue?

Thanks in advance.

0 likes
6 replies
sutherland's avatar

It sounds like you just need to create the symbolic link on the server as well. Run the same command you used locally to create the link and you should be fine.

mattnewark's avatar

Hi @sutherland

Thanks for the info, my remote site is running on a centos box, have you any idea how I would run the artisan cmd to get that working?

Is there another way of doing this?

Thanks

sutherland's avatar

Connect to the server via SSH and run the artisan command in your project directory. If you aren't using git for version control I highly recommend it. I know I could use it better but as a starting point it at least makes deployments a lot easier. I just set up a server the other day that has a hook to automatically create a symbolic link whenever I push code to the server.

mattnewark's avatar

hi @sutherland,

For some unknown reason I am unable to access the server do be able to do the command.

Is there another way of getting this work other than making the symbolic link?

Thanks

sutherland's avatar

You don't have SSH access to the server? What are you hosting it on? If you only have FTP access I don't believe you can create symlinks.

mattnewark's avatar
mattnewark
OP
Best Answer
Level 2

Morning @sutherland,

Its a long story, I have worked out another way of doing this: So in the filesystem.php I have added the below under disks:

        'uploads' => [
            'driver' => 'local',
            'root'   => public_path() . '/images',
        ],

and then I referenced it in my code :

$icon = $request->icon->getClientOriginalName();
            $main = $request->image->getClientOriginalName();
            $request->icon->storeAs('uploads/icon', $icon, 'uploads');
            $request->image->storeAs('uploads', $main, 'uploads');

Thanks for your help..

Please or to participate in this conversation.