Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

TUSHAR2004's avatar

Image source not readable!

Hi,

I have an application which is using the intervention/image package. In my controller file AdminCoursesController.php I have a method show_signatories which I am using to retrieve an image from the 'certificate_logo' directory, located in my public directory. But when I try to retrieve it I am getting 'Image source not readable' error from the intervention/image package. I have checked the directory, and the image exists.

Code is listed below:

AdminCoursesController.php

    public function show_signatories() {
        $signatories = Signatory::all();
        $inactive_signatories = Signatory::whereStatus(0)->get();
        $certificate_logo = CertificateLogo::whereStatus(1)->get()->first();
        if(empty($certificate_logo)) {
            $certificate_logo = 'some-image.jpg';
        }else{
            $certificate_logo = $certificate_logo->path;
        }

        $file = Image::make('certificate_logo/' . $certificate_logo);
        return $file->response('jpeg');     
    }

So, can you please help me debug what's causing this issue and how to resolve it?

Thanks

0 likes
5 replies
devfrey's avatar

Make sure the path is correct. Try referencing the file using an absolute path. Otherwise, your file permissions may be incorrect.

TUSHAR2004's avatar

I have double-checked the permissions, they are all fine. And I have also tried using the absolute path.

The strangest part is that when I upload an image, it is being uploaded to the 'certificate_logo' directory but when I try to access the image, it gives me an error. I tried to debug it by looking into the console and found that the header consisted of content-type: text/html instead of content-type: image/jpeg

Could this be the crux?

ftiersch's avatar

Which header do you mean? The header is just for requests and responses, not for the files on the server.

TUSHAR2004's avatar

Thanks @devfrey and @ftiersch for your replies. I was using following code to upload the file

$image->save(public_path() . '/certificate_logo/ ' . $filename);

Whereas it should have been like

$image->save(public_path() . '/certificate_logo/' . $filename);

An extra space (after -/certificate_logo/) was being added to the filename which was causing the problem.

munazzil's avatar

Can you change this $certificate_logo = CertificateLogo::whereStatus(1)->get()->first(); code as like below because you can either use first() or get() method,

        $certificate_logo = CertificateLogo::whereStatus(1)->get();

Please or to participate in this conversation.