Search code examples
phpimagelaraveluploadintervention

Laravel Intervention NotReadableException "Image source not readable" only on staging server


I'm developing a Laravel application that makes use of the Intervention Image Library. After successfully developing an image upload system, I encountered a problem on the staging server. When I upload an image, I get the following exception:

NotReadableException in AbstractDecoder.php line 302:
Image source not readable
in AbstractDecoder.php line 302
at AbstractDecoder->init('/var/www/yoosit.com/public') in AbstractDriver.php line 64
at AbstractDriver->init('/var/www/yoosit.com/public') in ImageManager.php line 50
at ImageManager->make('/var/www/yoosit.com/public') in ImageManagerStatic.php line 57
at ImageManagerStatic::make('/var/www/yoosit.com/public') in ImageController.php line 90
at ImageController->upload(object(UploadImageRequest))

Here is the code where stuff goes wrong:

$images = $request->only('image_1','image_2','image_3','image_4','image_5',
    'image_6','image_7','image_8','image_9','image_10');

foreach($images as $key => $image)
{
    // Continue loop if image input is empty.
    if ($image === null)
    {
        continue;
    }

    $interventionImage = InterventionImage::make($request->file($key)->getRealPath());

The exception is thrown when the last line where the instance is made is executed. I find this very odd because in my local environment (Homestead), I can upload images just fine.

I've already checked permissions and the folder is definitely writable. I'm running Debian 7 on a DigitalOcean VPS.

Any ideas? Thanks in advance!

P.S. I'm the static call to InterventionImage is just Intervention, normally it's Image::make but I save information about images to my database so I already have a model with the same name.


Solution

  • Have you checked that the images are actually uploaded? It could be for instance that your staging environment doesn't allow the upload size.