Back

Can't show image!


behnampmdg3 posted 3 years ago

Hi;

I get "The image cannot be displayed because it contains errors" message for some reason!

It does find the image because if i change the filename it gives me file-get_content error. So that part is right.


public function thumb($directory, $id, $file)
	{
		$image = file_get_contents(base_path().'/uploads/'.$directory.'/'.$id.'/thumb/'.$file);
		$response = Response::make($image, 200);
    	        $response->headers->set('Content-Type', 'image/jpeg');
    	        return $response;
	}

This is what it looks like

And if I dd($response) before return I get this:

This link

I get the same with


header('Content-Type: image/jpeg');
imagejpeg(file_get_contents(base_path().'/uploads/'.$directory.'/'.$id.'/thumb/'.$file));

I appreciate any help.

Thanks

pmall replied 3 years ago

Remove the header and it will display the error.

behnampmdg3 replied 3 years ago

pmall said:

Remove the header and it will display the error.

I get this

behnampmdg3 replied 3 years ago Solution

You wont believe it!!!!!

There was a white space on top of routes.php!!!!!!!

pmall replied 3 years ago

Always be careful about routes.php ... haha :)

manticorp replied 1 year ago

behnampmdg3 said:

You wont believe it!!!!!

There was a white space on top of routes.php!!!!!!!

Omg thank you. I spent hours searching for the solution to this.


Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us