Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not find the image error in Laravel #359

Open
Exoseed opened this issue Dec 23, 2022 · 0 comments
Open

Could not find the image error in Laravel #359

Exoseed opened this issue Dec 23, 2022 · 0 comments

Comments

@Exoseed
Copy link

Exoseed commented Dec 23, 2022

Hello,

I have a weird issue with Glide on a fresh local Laravel install (PHP 8.1.13 / Laravel 9.44.0). I followed the documentation to the letter, my route looks like this:

Route::get('/img/{path}', [ImageController::class, 'show'])->where('path', '.*');

I have an ImageController that looks like this:

namespace App\Http\Controllers;

use Illuminate\Contracts\Filesystem\Filesystem;
use League\Glide\Responses\LaravelResponseFactory;
use League\Glide\ServerFactory;

class ImageController extends Controller
{
    public function show(Filesystem $filesystem, $path)
    {
        $server = ServerFactory::create([
            'response' => new LaravelResponseFactory(app('request')),
            'source' => $filesystem->getDriver(),
            'cache' => $filesystem->getDriver(),
            'cache_path_prefix' => '.cache',
        ]);

        return $server->getImageResponse($path, request()->all());
    }
}

But when I try to access an image through the correct path, it gives me a "Could not find the image storage/images/portrait-rose.jpg." error.

Url is: http://localhost:8000/img/storage/images/portrait-rose.jpg

And if I try to access http://localhost:8000/storage/images/portrait-rose.jpg the image definitely shows up.
What could be the issue there?

Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant