简体   繁体   中英

unable to retrieve images uploaded on aws instance using laravel

i am trying to upload image via laravel and then retrieve its url to save in database and return back to the front end application , image upload is working fine at localhost but not at ec2 instance .

Image is uploaded successfully and can be downloaded via filezilla also

i have setup chmod -R 777 for the storage directory in laravel but its still not working

public static function upload_files($type, $file, $id)

{
    if ($type == 'profile_pic') {
        $image = $file->store('profile_pic','public');
         $image = asset('storage/'.$image);
        if ($image) {
            return $image;
        } else {
            return false;
        }
    }
}

it return http://localhost/trip/public/storage/profile_pic/MaHskQD2VcLSlC11VV3agbBNdh7j7k82liewYBw3.png at localhost and when i click on the link, image is loaded successfully while on my server it loads http://mydomain/storage/app/profile_pic/MaHskQD2VcLSlC11VV3agbBNdh7j7k82liewYBw3.png and throws 404 not found error

result of ls -lrt is "-rwxrwxrwx 1 apache ec2-user 190916 Jan 23 10:06 MaHskQD2VcLSlC11VV3agbBNdh7j7k82liewYBw3.png"

请在您的mydomain终端上运行以下命令:

php artisan storage:link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM