X-Mac
267
8
Laravel

Retrieve image from storage

Posted 8 months ago by X-Mac

Hi, I stored the image in storage /app /signs/intervento_x/sign.png

now I would retrieve the image, but my code not working Preface: I don't know how create a symbolic link on server because I don't have composer.

This is my code: view : <img class="report" src='{{url('reportIntervento.jpg')}}' style='width:760px; height: 940px'>

      </div>

Controller :

$filename = 'signs/intervento_'.$intervento_id.'/sign.png'; ..... route

Route::get('signs/{filename}', function ($filename) { $path = storage_path() . 'app/signs/' . $filename;

if(!File::exists($path)) abort(404);

$file = File::get($path);
$type = File::mimeType($path);

$response = Response::make($file, 200);
$response->header("Content-Type", $type);
return $response;

})->name('signs');

any chance to retrieve the image ?

thanks a lot

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.