SilvioDev's avatar

limited access to public image folder

Users can upload profil images to public folder with Laravel-Stapler extension. I have the subfolder system/images/... in my public folder where the images will be saved.

But now it's possible to show the pictures if i enter localhost/mypage/system/images/exampleimage.jpg.

How can i deny the directly access? I just want to show the images via html. Tobody elso should have access to the private images.

Before i tried to store the images in app/storrage folder. But i had problems to show or refresh the images sometimes.

Any help?

0 likes
2 replies
SilvioDev's avatar

I store my images now in the app/storage folder. But i cant show the picture:

$sportler->image->url('medium');  returns the path to the image =  "/system/Sportler/images/000/000/023/medium/z2.1.png"

routes.php
Route::get('/images/{path}', function($path) {
    $path = storage_path().'/uploads'.$path;

    $response = Response::make(
     File::get($path), 
     200
    );
    $response->header(
    'Content-type',
    'image/png'
    );
    return $response;
});

But if i try to open the route and get the image it doesn't work

{{HTML::image('/images/'.$sportler->image->url('medium'), $alt="Photo", $attributes = array()) }}

How can i return the rsponse by calling the route to get the image?

Please or to participate in this conversation.