Mav23Sa's avatar

problem in shared server

I am trying to get my system working. In fact it is already working. But the files that users upload (profile images) are no longer working. the problem is that they are loaded but not moved to the public folder.

I clarify that it is a shared server. I think my problem is in the link to the folder. How can I create it?

0 likes
14 replies
jlrdw's avatar

Probably ssh in with putty or similar and set the link. Or command line if you have access.

Edit: But on shared, you can still serve from the public folder if you need to.

Make sure you have pointed to public as document root, see the deployment section of the laravel documentation.

Mav23Sa's avatar

that would be nice, but my server does not have access to the terminal

jlrdw's avatar

You should have ssh access with a program like putty. What host?

Mav23Sa's avatar

I use neubox.net, it doesn't give me access to the terminal, or ssh, or run symlink with php

Mav23Sa's avatar

okay. I explain a little more. I don't know what the problem really is

I use livewire to load the photos of users with the following code

$path = $this->photo->store('profile_pic', 'public');
$user->profile_photo_path = url('storage/'.$path);
$user->save()

and to show it I just use

<img src="$user->profile_photo_path">

charging is successful but when displaying the image it tells me that the file does not exist

Mav23Sa's avatar

I do not have access to the terminal. the hosting provider just confirmed to me that it is not possible to create shortcuts (symlink)

What other solution can I have?

jlrdw's avatar

Just put them in public then. public\images. OR where ever.

Mav23Sa's avatar

how?

I'm doing just that here

$path = $this->photo->store('profile_pic', 'public');

How can I physically move the file to the public / profile_pic folder

jlrdw's avatar

Use move, you can set the path and just put the image there.

I am on mobile I will boot up desktop.

jlrdw's avatar
            $lid = DB::table('dc_dogs')->count();
            $lid = $lid + 1;
            $file = Request::file('ufile');
            $file_name = $file->getClientOriginalName();
            $file_ext = $file->getClientOriginalExtension();

            $fileInfo = pathinfo($file_name);
            $filename = $fileInfo['filename'];
            $newname = $filename . $lid . "." . $file_ext;
            $destinationPath = ASSET . 'upload/imgdogs';
            $file->move($destinationPath, $newname);

            $dogpic = $newname;
            $dogname = ucfirst(Request::input('dogname'));
            $sex = ucfirst(Request::input('sex'));
            $comments = Request::input('comments');
            $adopted = !empty(Request::input('adopted')) ? '1' : '0';
            $lastedit = date("Y-m-d H:i:s");


            $postdata = array(
                'dogpic' => $dogpic,
                'dogname' => $dogname,
                'sex' => $sex,
                'comments' => $comments,
                'adopted' => $adopted,
                'lastedit' => $lastedit
            );

            DB::table('dc_dogs')->insert($postdata);

I made ASSET above a constant to path. Use your path

To display:

<img width="100" style="border: none;" src="<?php echo DIR . 'assets/upload/imgdogs/' . $row->dogpic; ?>" alt="">

Where DIR is a constant for base url.

I also in blade:

<img src="{{ asset('assets/upload/imgdogs') . '/' . $row->dogpic }}" alt="" class="image">

All the above works been working since laravel 5.1 through laravel 8.

Also the constant for asset:

define('ASSET', realpath(dirname(__FILE__)). DS . 'assets' . DS);

DS is

defined('DS') || define('DS', DIRECTORY_SEPARATOR);
Snapey's avatar

look at filesystems.php in the config folder

read the docs about filesystems

change the local disk to be the public folder instead of the storage folder

or, get a decent hosting provider

Please or to participate in this conversation.