skip to Main Content

I have an image upload form in my Laravel project.

I want to save the uploaded image into public/images/ location.

But image upload into public/app/images location.

From where this app is coming!!

config/filesystem.php

'disks' => [

 'local' => [
    'driver' => 'local',
    'root' => public_path(''),
],

'public' => [
    'driver' => 'local',
    'root' => public_path(''),
    'visibility' => 'public',
],

's3' => [
    'driver' => 's3',
    'key' => 'your-key',
    'secret' => 'your-secret',
    'region' => 'your-region',
    'bucket' => 'your-bucket',
  ],
],

controller

if($this->request->hasFile('photo')) 
{
    $image_url = $this->request->photo->store('/images/campaign/large');

    $image = substr($image_url, strrpos($image_url, '/') + 1);
}

I have applied the same code in my local project. Image uploaded there in the correct location.

But this problem happens in my cPanel server project. I have already clear cash in live server.

Where is the mistake?

3

Answers


  1. I think this Controller code help you.

    if($this->request->hasFile('photo')) 
    {
        $image_url = $this->request->photo->store(public_path('images'));
    
        $image = substr($image_url, strrpos($image_url, '/') + 1);
    }
    
    Login or Signup to reply.
  2. Maybe you can chmod -R 777 your directory file, if you using linux or mac os, or you cant clear the cache, because yesterday in my office .

    This of full :
    https://kb.iu.edu/d/ahic

    Login or Signup to reply.
  3. I think you have missed to create a symbolic link for the storage path.
    Please follow this link: Larvel Public Disk

    In short you need to run this
    php artisan storage:link

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