Jump to content
JMH

Internal Server Error when uploading an image

Recommended Posts

Hi all,

I'm trying to upload an image to a blog post. The ProcessWire blog editing page is relatively simple. See attached. When I try to add more images and publish the post an internal server error is returned and a blank space is where the additional images should be. 

Can anyone advise on how this can be resolved quickly.

Please let me know any additional information you'd need. 

Many thanks.

JMH 

 

Internal Server Error 500.png

Blog Editing Page.png

Share this post


Link to post
Share on other sites

Errors like this are often caused by too large images. When you request a certain size, both the original image and the resized one (plus some computational overhead) have to be read into the main memory, so it's possible you're hitting PHP's memory limit.

Share this post


Link to post
Share on other sites

Am I seeing things, or are you actually running the TinyMCE module instead of the default CKEditor? What version of PW?

 

  • Like 1

Share this post


Link to post
Share on other sites
16 hours ago, BitPoet said:

Errors like this are often caused by too large images. When you request a certain size, both the original image and the resized one (plus some computational overhead) have to be read into the main memory, so it's possible you're hitting PHP's memory limit.

Thanks for getting back to me. Is there a standardised memory limit for PHP. I've resized the files and used compressed versions, but i still see the same error. My hosting provider has come back with the following feedback any additional thoughts:

2) Internal Error 500) 
The error logs show the following: 
[Tue Oct 11 09:06:57 2016] [error] [client 199.16.156.125:53266] Script timed out before returning headers: index.php
[Tue Oct 11 09:07:04 2016] [warn] [client 199.16.156.125:56282] AH01220: Timeout waiting for output fromCGI script /home/sites/public_html/index.php
[Tue Oct 11 09:07:04 2016] [error] [client 199.16.156.125:56282] Script timed out before returning headers: index.php
[Tue Oct 11 09:11:57 2016] [warn] [client 199.16.156.125:53266] AH01220: Timeout waiting for output fromCGI script /home/sites/public_html/index.php
[Tue Oct 11 09:12:04 2016] [warn] [client 199.16.156.125:56282] AH01220: Timeout waiting for output fromCGI script /home/sites/public_html/index.php

Why the site is taking so long to run the script, I'm unable to see why - but we cut off scripts from running longer than 30 seconds. This isn't something we're able to bypass. If the image you're trying to upload is rather large, it could be taking a while for the CMS to process it which is why it fails.

 

 

 

Share this post


Link to post
Share on other sites

PHP's memory limit is an ini setting just like the maximum script execution and set by your hoster. Perhaps you can try with a truly small image and see if this works, just to make sure it is really a case of the script taking too long vs. the script crashing without the CGI handler realising it. If this works, you could try and go up in steps to get a feel where the size limit is. I'm not sure what's the best way to get some sensible debugging information about that, perhaps someone more familiar with the image modules can chime in here.

  • Like 1

Share this post


Link to post
Share on other sites
16 hours ago, adrian said:

Am I seeing things, or are you actually running the TinyMCE module instead of the default CKEditor? What version of PW?

 

New to ProcessWire, must be an old version. Is CKEditor out of beta now?

Share this post


Link to post
Share on other sites
1 minute ago, JMH said:

New to ProcessWire, must be an old version. Is CKEditor out of beta now?

CkEditor itself has been around for a very long time and the default editor in PW since July 2014 :)

Before you do anything else, go grab the latest version of PW here: https://github.com/processwire/processwire

  • Like 1

Share this post


Link to post
Share on other sites
11 minutes ago, adrian said:

CkEditor itself has been around for a very long time and the default editor in PW since July 2014 :)

Before you do anything else, go grab the latest version of PW here: https://github.com/processwire/processwire

Great, thanks Adrain. As i mentioned the team is new to PW, so I'm wary of the update being problematic. 

Share this post


Link to post
Share on other sites

With newer PW versions there is, besides a billion other new goodies, also integrated memory checking before trying to manipulate / create a(n) image / variation.

  • Like 1

Share this post


Link to post
Share on other sites
20 hours ago, adrian said:

CkEditor itself has been around for a very long time and the default editor in PW since July 2014 :)

Before you do anything else, go grab the latest version of PW here: https://github.com/processwire/processwire

So it looks like I'm running version 2.3.0 of ProcessWire that dates back to 2013. Seems like an upgrade is in dire need. My hosting provider's servers are using the following versions of software. Can you advise on the best version to upgrade to please? Also will this solve the issue with image uploads?? 

  • Apache 2.4.6 with all standard modules installed, including mod_rewrite
  • MySQL version 5.5.32 (MySQL version 5.1.73 for unmanaged servers)
  • PHP version 4.4.9 with Zend Optimiser version 3.3.3
  • PHP version 5.2.17 with Zend Optimiser version 3.3.9
  • PHP version 5.3.27
  • PHP version 5.4.16
  • PHP version 5.5.1
  • Perl version 5.10.1 with Crypt::SSLeay module version 0.57
  • Python version 2.6.6
  • Ruby version 1.8.7 and eRuby (embedded Ruby)
  • Image::Magick version 6.8.3-6
  • GD version 2.3.5
  • CURL version 7.19.7

 

Share this post


Link to post
Share on other sites

The server software looks good. I would select PHP 5.4.x or higher.

Upgrading to PHP 2.7, the legacy Version at a first step should be relatively safe, depending on the third party modules you run into that site.

Can you post a list of all installed and used site/modules ?

Regardless of that, you first should backup a mysql dump and the complete site folder!

If you can, you than should install (locally?) a copy of that site and test the upgrade there.

If not, it is also possible to do it on the live site, if you:

  • can set it into maintenance mode some how
  • have an external access to the mysql DB for backup and restore operations

 

  • Like 2

Share this post


Link to post
Share on other sites
3 minutes ago, horst said:

The server software looks good. I would select PHP 5.4.x or higher.

Upgrading to PHP 2.7, the legacy Version at a first step should be relatively safe, depending on the third party modules you run into that site.

Can you post a list of all installed and used site/modules ?

Regardless of that, you first should backup a mysql dump and the complete site folder!

If you can, you than should install (locally?) a copy of that site and test the upgrade there.

If not, it is also possible to do it on the live site, if you:

  • can set it into maintenance mode some how
  • have an external access to the mysql DB for backup and restore operations

 

I've downloaded the full site (1.7GB) and mysql (1.9MB). Also created a copy of the site for non-production version to test the upgrade with. All the modules used should be in images attached. At least I think they're all listed. Thanks for getting back to me. Much appreciated. 

Production Site Modules.png

Wire Modules1.png

Wire Modules2.png

Wire Modules3.png

Wire Modules4.png

Wire Modules5.png

Wire Modules6.png

Wire Modules7.png

Share this post


Link to post
Share on other sites

As a side note: you have the install (sub)folder in your production site? (this should be deleted on production sites after successful installation)

There are not much third party modules. Following these steps should do it, hopefully:

  • start your local copy and check if everything is working as expected, front and backend
  • make a mysql dump of the local DB
  • download the PW 2.7 legacy version
  • rename your existing wire folder to wire.2-3, your index.php to index.php.2-3 and the .htaccess to .htaccess.2-3
  • copy the wire folder, the index.php and the .htaccess (htaccess.txt => .htaccess) from the PW 2.7 distribution to your local copy
  • now load / reload a multiple times the backend and look out for messages. (turn on $config->debug = true; in your site/config.php)

If this above steps will do, you additionally will need to change every html-editor textarea field type to work with CK-Editor, instead of the old, (now in the core missing TinyMCE). I don't recall any other things should take care of. The site/templates-admin/ folder can be deleted in your site profile too, after the successful upgrade to 2.7.

If there will raise any other issue, please come back here and tell us. :)

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, horst said:

As a side note: you have the install (sub)folder in your production site? (this should be deleted on production sites after successful installation)

There are not much third party modules. Following these steps should do it, hopefully:

  • start your local copy and check if everything is working as expected, front and backend
  • make a mysql dump of the local DB
  • download the PW 2.7 legacy version
  • rename your existing wire folder to wire.2-3, your index.php to index.php.2-3 and the .htaccess to .htaccess.2-3
  • copy the wire folder, the index.php and the .htaccess (htaccess.txt => .htaccess) from the PW 2.7 distribution to your local copy
  • now load / reload a multiple times the backend and look out for messages. (turn on $config->debug = true; in your site/config.php)

If this above steps will do, you additionally will need to change every html-editor textarea field type to work with CK-Editor, instead of the old, (now in the core missing TinyMCE). I don't recall any other things should take care of. The site/templates-admin/ folder can be deleted in your site profile too, after the successful upgrade to 2.7.

If there will raise any other issue, please come back here and tell us. :)

Thanks Horst. Just spoke with hosting provider and they've said I can create dev folder in public_html and test the upgrade files through their file manager. Does this make sense to based on everything you've advised so far? 

Dev 1 copy.png

Share this post


Link to post
Share on other sites

What you need is a complete copy of your production site. That includes all files from wire and all files from site, plus index.php and .htaccess. Additonal to this you need a dev-mysql DB that is an exact copy of that DB of your production site. ATTENTION: the site/config.php file of your dev-copy need to be adjusted to point to the dev-DB, and not to the production DB anymore!

The dev-copy should be on its own domain or subdomain. How can you call / access your dev-copy via HTTP?

It better should not exist in a subfolder of your production webroot.

If your production site is http://example.com/, the devcopy should NOT be accessible via http://example.com/devcopy/, but can be a subdomain like http://dev.example.com/

 

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By fruid
      I'm using custom fields for images (as mentioned here: processwire.com/blog/posts/pw-3.0.142) for a specific images-field, the images of which need to have an HTML-caption. It works fine so far. Now I'm trying to import pages that use this field. I first exported some pages of that kind to see what the spreadsheet would look like. It seems to not separate the captions for each images but instead put all images in one cell and all captions in another.
      How could I go about importing these pages and assign the captions to the images accordingly?
    • By longtom
      I'm creating this site where a 'motherpage' renders all subpages.  I switched on frontend editing to make editing as easy as possible to end-users. 
      I'm stuck on adding images to the subpages.  The frontend editor suggests to add images to the motherpage (that has no images field on it, nor should it), so it asks for another page to add the images to/from. 
      Is there a way to make the frontend-editor context aware so that it looks for images in the correct subpage? 
      I already tried the 'type C' approach and added <edit field="body" page="id">, but that doesn't seem to do the trick. 
    • By Rossie
      Hi Everyone,
      I wish to display a gallery of images from multiple pages on the site.  These images have custom fields created through page reference called 'furniture_list_type'.  Each image now has a radio button which has been selected.
      In  the example code below all images appear from the "gallery20", however the selector  "gallery20.furniture_list_type=3390" does not have any effect.  "3390" is the id of the page reference "chair" selected through the page reference.  I wish only images selected as chair to show.
      Hope someone can help with this.
       
      Thanks,
       
      Calum
       
      $imagePages = $pages->find("template=makers-child, gallery20.furniture_list_type=3390") ;                     foreach($imagePages as $p) {     echo "<ul>";     foreach($p->gallery20 as $image) {         echo "<li><img src='{$image->url}'>{$image->furniture_list_type}</li>";     }     echo "</ul>";      }
    • By daniel_puehringer
      Hey,

      so we all know about SEO and the importance of performance. Basically we do it, because if no one finds the website we just built, it´s frustrating. We all try to write clean markup, css and js code and most might have a webpack/gulp/whatever pipeline to minimize css&js.
      But when thinking about it, optimizing your pipeline might save you a few (hundreds) of kb, compared to loading an image with 1 mb that´s literally nothing and frankly just ridiculous.

      Don´t get me wrong, frontend pipelines are great and should be used, but let´s shift your "I will optimize the shit out of that 3 css lines" focus to something different: try to serve images as fast as possible, this is where the performance boost really happens.

      I´m no pro on processwire so far, but I built a very easy to use picture element, which some of you could find interesting:

      1. the picture comes with 3 different sizes: one for mobile (keep in mind the double dpi, therefore width of 828px), one for tablet and one for desktop
      2. the picture generates a webp version and the original file extension as a fallback
      3. the filesize of each element is rendered within the "data" attribute
      4. lazy loading(sooo important!!!) is done via the native 'loading="lazy"' attribute.


      Please try it out and see the difference 🙂

      I posted this so others can easily optimize their images, but I would also like to hear your suggestions in making it better. Maybe you could decrease the rendering time or maybe you have some easy improvements.

      Please let me know.

      Greetings from Austria!


       
      <picture> <source data="<?php echo($oElement->repeater_image->width(828)->webp->filesize);?>" media="(max-width: 414px)" srcset="<?php echo($oElement->repeater_image->width(828)->webp->url) ?> 2x" type="image/webp"> <source data="<?php echo($oElement->repeater_image->width(828)->filesize) ?>" media="(max-width: 414px)" srcset="<?php echo($oElement->repeater_image->width(828)->url) ?> 2x" type="image/<?php echo($oElement->repeater_image->ext)?>"> <source data="<?php echo($oElement->repeater_image->width(767)->webp->filesize) ?>" media="(min-width: 415) and (max-width: 767px)" srcset="<?php echo($oElement->repeater_image->width(767)->webp->url) ?> 2x" type="image/webp"> <source data="<?php echo($oElement->repeater_image->width(767)->filesize) ?>" media="(min-width: 415) and (max-width: 767px)" srcset="<?php echo($oElement->repeater_image->width(767)->url) ?> 2x" type="image/<?php echo($oElement->repeater_image->ext)?>"> <source data="<?php echo($oElement->repeater_image->webp->filesize) ?>" media="(min-width: 768px)" srcset="<?php echo($oElement->repeater_image->webp->url) ?>" type="image/webp"> <source data="<?php echo($oElement->repeater_image->filesize) ?>" media="(min-width: 768px)" srcset="<?php echo($oElement->repeater_image->url) ?>" type="image/<?php echo($oElement->repeater_image->ext)?>"> <img data="<?php echo($oElement->repeater_image->filesize) ?>" class="img-fluid" loading="lazy" src="<?php echo($oElement->repeater_image->url) ?>" alt="<?php echo($oElement->repeater_image->description) ?>" type="image/<?php echo($oElement->repeater_image->ext)?>"> </picture>
    • By picarica
      so hello i am trying to combine my whole ass gallery with custom created watermark, i wanted to combine my images with simple text little opaque but that seemed harder and i couldnt make it work, well i cant make this work either, how are you handling watermarks? i would prefer if it would be plain PHP no imagemagick or some custom plugins scripts, but if neccesary i wont deny.
      so here's my code
      $pa = $pages->find("template=basic-page|art_gallery, images.tags!=''"); /* $pa = $pages->find("has_parent!=2,id!=2|7,status<".Page::statusTrash.",include=all"); */ echo "<div BRUUH class='row gtr-50 gtr-uniform js-filter' id='gal' >"; foreach ($pa as $p) { foreach($p->images as $image) { $obrazok = $image->url; $image = imagecreatefromjpeg($obrazok); $frame = imagecreatefromjpeg($pages->get('/settings/')->watermark->url); /* echo $image; echo $frame; */ # If you know your originals are of type PNG. imagecopymerge($image, $frame, 0, 0, 0, 0, 50, 50, 100); # Output straight to the browser. $img = imagepng($image); $options = array('quality' => 70, 'upscaling' => true, 'cropping' => 'center', 'sharpening'=>'medium'); $thumb = $img->size(400, 300, $options); $large = $img->size(1200, 0, $options); echo "<div class='$image->tags' class='col-4'>"; echo "<span style='overflow:hidden;'class='image fit'>"; echo "<a href='$large->url'>"; echo "<img class='uk-transform-origin-top-right' uk-scrollspy='cls: uk-animation-fade; repeat: false' src='$thumb->url' alt='$image->tags'>"; echo "</a>"; echo "</span>"; echo "</div>"; } };  
×
×
  • Create New...