CRUD: [Bug] Image field cannot be used with big sized image

Bug report

What I did

I made a crud controller using image field. Here’s the image field’s declaration:

CRUD::field('featured_image')
            ->type('image')
            ->label('Featured Image')
            ->crop(true)
            ->aspect_ratio(1.96)
            ->disk('public');

What I expected to happen

Image cropped and uploaded as usual

What happened

for some reason when I use images with big size or big resolution, it returns error 404 method not found for POST /admin/{entity}/{primary_key}

image

image

image

What I’ve already tried to fix it

  • resize the image to small resolution (around 700-800px width) so backpack won’t return 404 error. (always works)
  • convert the image to .jpg (sometimes still return 404 error, intermittent)

And also, this is error is not showing in my local machine. So this is either because of server error, connection (images took some time to upload to server, unlike in localhost), or the particular image problem

Backpack, Laravel, PHP, DB version

When I run php artisan backpack:version the output is:

Local:

PHP VERSION:

PHP 7.4.5 (cli) (built: Apr 14 2020 16:17:34) ( ZTS Visual C++ 2017 x64 ) Copyright © The PHP Group Zend Engine v3.4.0, Copyright © Zend Technologies

LARAVEL VERSION:

v8.19.0@f5f331cee60f1bbe672503b7eb9ba5b22b2ceacb

BACKPACK VERSION:

4.1.30@62856b1f01fc3e05c80140fc22f85ea2aac8368c

Server:

PHP VERSION:

PHP 7.4.13 (cli) (built: Nov 25 2020 21:00:01) ( NTS ) Copyright © The PHP Group Zend Engine v3.4.0, Copyright © Zend Technologies with Zend OPcache v7.4.13, Copyright ©, by Zend Technologies

LARAVEL VERSION:

v8.19.0@f5f331cee60f1bbe672503b7eb9ba5b22b2ceacb

BACKPACK VERSION:

4.1.30@62856b1f01fc3e05c80140fc22f85ea2aac8368c

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (17 by maintainers)

Commits related to this issue

Most upvoted comments

@mahasadhu end up creating the PR, thinking about it twice, it may help some 😅 https://github.com/Laravel-Backpack/docs/pull/239

No problem @promatik 🤝 Yea it could be, since the image field send the image as base64 string (CMIIW).

Understood, if you need me to update the issue title so it can be more easily searched, just tell me.

I’ve also tried to find how to disable those extensions programmatically, but so far no success 😅 I’ll post later if I got any ways to work around it.

Thank you!

@promatik I found it!!

The problem was in PHP’s apcu and opcache extension!

When I disabled those two extensions, the big image uploads normally

Additionally, in some shared hosting provider sometimes they use ModSecurity (https://modsecurity.org/). That also needs to be disabled in order the image fields to work.

What do you think about this @promatik ?

I’ll report later when I found another conflicting things with Backpack