Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

helpmyworld's avatar

Laravel - Image created and stored but not displaying on production but work on local

my website or project runs and always has been working well until I upgrade to Laravel 10 (the upgrade to Laravel 10 is not a problem). My website/project is a blog. Blog posts I posted from last year 25 December 23 back to the fist post show and display images stored in public_html/images. After I uploaded the upgrade. I tried to post, the post is created, images shows it is uploaded in the database but for some reason it has created a folder in my laravel project projectname/public/images - now these new images don't display on on the views but the old blog post images are showing in the views. I haven't changed any code, just upgrade since my website is been working for years.

What I want is for image to be stored in public_html/images and show. *NOTE: I am using whm centos server. /home/rorisangproject/laravelcode/ in here its the code, .env /home/rorisangproject/public_html/ where index, images, css are stored

Controller still fine haven't made changes

public function store(Request $request)
    {
        $this->validate($request,[
            'title' => 'required',
            'cats' => 'required',
            'tags' => 'required',
            'body' => 'required',
        ]);
        $post = $request->file('image');
        $slug = str_slug($request->title);
        if ($request->hasFile('image')) {
            $image = $request->file('image');
            $filename = time() . '.' . $image->getClientOriginalExtension();
            $location = public_path('images/' . $filename);
            Image::make($image)->resize(800, 400)->save($location);
            $post->image = $filename;

//code is fine I am sure

View

<img decoding="async" class="alignnone size-large wp-image-37576" src="{{asset('/images/' . $post->image)}}" alt="" width="600" height="600">

Please advise where I am going wrong. my website is running rorisangmaimane.co.za but I can't upload new images.

0 likes
10 replies
tisuchi's avatar

@helpmyworld Can you confirm two things?

  • Run php artisan storage:link for Symbolic link
  • Provide the right permission for public_html/images
1 like
helpmyworld's avatar

@tisuchi yes when I run "php artisan storage:link" in /home/rorisangmamane/rorisang/ I get an error " ErrorException

symlink(): No such file or directory"

Yes I provided permission for public_html/

I just deleted the folder "public" under /rorisangmaimane/rorisang/public (deleted this public folder) and I am getting the error "Can't write image data to path (/home/rorisangmaimane/rorisang/public/images/1705572647.jpg)" which shows that files are stored in public under rorisang where else they should be in public_html/images

helpmyworld's avatar

@tisuchi Could it be that you are suggesting that I can store images in /rorisang/public/images -- then the symbolic link can somehow pull the form public_html/images ?

gych's avatar

So if I understand it right, your new images are stored in public/images but you need them to be stored in public_html/images for them work ?

helpmyworld's avatar

@gych yes I want images to be stored in public_html/images. For the reason that the website is live now, and the images I uploaded for the past years are being pulled and displayed form public_html/ and also It always worked that way. I don't understand why the change now. I just deleted the folder "public" from home/rorisangmaimane/rorisang/public/. I want to force it to store the images in public_html

gych's avatar

@helpmyworld Just use public/images to store your images and make a symlink between public/images and public_html/images. I do it like this for my projects.

Make a backup of your images before you do this, so nothing gets lost if something goes wrong

This is the CMD you have to write in your terminal to make the link with your terminal pointing to the folder of your laravel app where the public folder is located

ln -sr public/images ../public_html/images 
helpmyworld's avatar

@gych Thank see this

"[10:39] [server1.62.66.225.66 rorisang] # ln -sr public/images ../public_html/images ln: failed to create symbolic link ‘../public_html/images/images’: File exists

gych's avatar
gych
Best Answer
Level 29

@helpmyworld Move all images from public_html/images to public/images and then delete the folder images in public_html after that try to make the symlink again

helpmyworld's avatar

@gych Thank you. I ran the command like so "[10:53] [server1.66.235.225.30 ~] # ln -s /home/rorisangmaimane/rorisang/public/images/ /home/rorisangmaimane/public_html/

It was driving me nuts. Thank you.

1 like

Please or to participate in this conversation.