Jump to content

Internal Server Error when uploading an image


JMH
 Share

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

Link to comment
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.

Link to comment
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.

 

 

 

Link to comment
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
Link to comment
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?

Link to comment
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

 

Link to comment
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
Link to comment
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

Link to comment
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
Link to comment
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

Link to comment
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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By eelkenet
      After enabling WebP support you may notice it can take a long time for ProcessWire to create WebP copies of all images and their variations.
      For instance, on a site I work on (with over 10k images), it was taking about 1 second per image, ie. more than 3 hours in total.. 🥱
      If you are comfortable around the command-line, you can use the cwebp program and this bash script to speed things up drastically.
      I have built upon this script and got things to work in combination with xargs and find, making it rather powerful for PW's purposes.
      1. Save this script as 'convert-webp.sh' (or download the Gist from Github), and follow instructions
      ######################################################################################################### # # Fast Recursive Images to WebP converter # Customized for ProcessWire CMS/CMF <https://www.processwire.com> # # Author: Eelke Feenstra <dev@eelke.net> # Version: 001 # Based upon: https://github.com/onadrog/bash-webp-converter # # Quick & dirty script to add webp versions to all PNG / JPG / JPEG files inside your PW assets folder # # 1. Set this script to executable: # $ chmod +x convert-webp.sh # # 2. Check if cwebp is installed: # $ cwebp -version # If it is not, install: # $ brew install webp # Or follow instructions https://developers.google.com/speed/webp/download # and change $executable to cwebp's full path # # 3. Run the script directly on a folder: # $ ./convert-webp.sh /path/to/your/folder # ######################################################################################################### # Configuration executable="cwebp" # update this to reflect your installation! quality=90 # change to desired WebP quality ######################################################################################################### converted=0 skipped=0 echo "Entering $1" for file in $1/* do name="${file%.*}" echo "FILE: $file" echo "NAME: $name" # Skip the folder itself.. if [ "$name" = "./." ]; then echo "SKIP: $name" continue; fi if [[ $(file --mime-type -b $name.webp) == image/webp ]]; then echo "FOUND: $name.webp, skipping.." skipped=$((skipped+1)) elif [[ $(file --mime-type -b $file) == image/*g ]]; then echo "NOT FOUND: $name.webp" newfile(){ echo "$file" | sed -r 's/(\.[a-z0-9]*$)/.webp/' } $executable -q $quality "$file" -short -o "$(newfile)" converted=$((converted+1)) fi done echo "Converted $converted, Skipped $skipped" 2. Run to create webp versions of all jpg/jpeg/png images in a given folder (for example the site's homepage)
      $ ./convert-webp.sh /path/to/processwire/site/assets/files/1 3. And in order to create WebP copies of ALL images inside the /site/assets/files folder, you can run this script. It searches for all directories inside the files directory, and passes these to the convert-webp.sh script using xargs.
      $ find /path/to/processwire/site/assets/files -maxdepth 2 -type d | xargs -I '{}' ./convert-webp.sh '{}'  
      Tested both on MacOS 12 and Debian
       
    • By quickjeff
      Hi Everyone, 
      As many of you know, iPhone photos save in .heic unless the user changes the settings in their phone. 
      We have built a web app on top of processwire in which a user can save images from their phone. 
      The issue we are having is that there seems to be an error when uploading and saving. 
      The .heic files won't save and processwire throws an error. The environment is LAMP (Bitnami and all libraries have been installed to support this.) 
      Checking to see if someone has also encountered this here and how they solved it.
      Thanks. 
    • By Robin S
      Select Images
      An inputfield that allows the visual selection and sorting of images, intended for use with the FieldtypeDynamicOptions module. Together these modules can be used to create a kind of "image reference" field.

      Integration with FieldtypeDynamicOptions
      InputfieldSelectImages was developed to be used together with FieldtypeDynamicOptions (v0.1.3 or newer):
      Create a Dynamic Options field. Choose "Select Images" as the "Inputfield type". Select Images appears in the "Multiple item selection" category but you can set "Maximum number of items" to 1 if you want to use Select Images for single image selections. Define selectable options for the field via a FieldtypeDynamicOptions::getSelectableOptions hook. See some examples below. FieldtypeDynamicOptions is recommended but is not a strict requirement for installing InputfieldSelectImages in case you want to use an alternative way to store the field data.
      Selection of Pageimages
      In this example the field allows selection of Pageimages that are in the "images" field of the home page.
      The field will store URLs to the Pageimages so it works as a kind of "image reference" field. You can use the "Format as Pagefile/Pageimage object(s)" option for the Dynamic Options field to have the formatted value of the field be automatically converted from the stored Pageimage URLs to Pageimage objects.
      $wire->addHookAfter('FieldtypeDynamicOptions::getSelectableOptions', function(HookEvent $event) { // The page being edited $page = $event->arguments(0); // The Dynamic Options field $field = $event->arguments(1); // For a field named "select_images" if($field->name === 'select_images') { $options = []; // Get Pageimages within the "images" field on the home page foreach($event->wire()->pages(1)->images as $image) { // Add an option for each Pageimage // When the key is a Pageimage URL the inputfield will automatically create a thumbnail // In this example the label includes the basename and the filesize /** @var Pageimage $image */ $options[$image->url] = "{$image->basename}<br>{$image->filesizeStr}"; } $event->return = $options; } }); Selection of image files not associated with a Page
      When not working with Pageimages you must add a "data-thumb" attribute for each selectable option which contains a URL to a thumbnail/image.
      In this example the field allows selection of image files in a "/pics/" folder which is in the site root.
      $wire->addHookAfter('FieldtypeDynamicOptions::getSelectableOptions', function(HookEvent $event) { // The page being edited $page = $event->arguments(0); // The Dynamic Options field $field = $event->arguments(1); // For a field named "select_images" if($field->name === 'select_images') { $options = []; // Get files that are in the /pics/ folder $root = $event->wire()->config->paths->root; $path = $root . 'pics/'; $files = $event->wire()->files->find($path); // Add an option for each file foreach($files as $file) { $basename = str_replace($path, '', $file); $url = str_replace($root, '/', $file); // The value must be an array with the following structure... $options[$url] = [ // The label for the image 'label' => $basename, 'attributes' => [ // An image URL in the "data-thumb" attribute 'data-thumb' => $url, ], ]; } $event->return = $options; } }); The field values don't have to be image URLs
      The values stored by the Dynamic Options field don't have to be image URLs. For example, you could use the images to represent different layout options for a page, or to represent widgets that will be inserted on the page.
      Also, you can use external URLs for the thumbnails. In the example below the options "calm" and "crazy" are represented by thumbnails from placecage.com.
      $wire->addHookAfter('FieldtypeDynamicOptions::getSelectableOptions', function(HookEvent $event) { // The page being edited $page = $event->arguments(0); // The Dynamic Options field $field = $event->arguments(1); // For a field named "calm_or_crazy" if($field->name === 'calm_or_crazy') { $options = []; // Add options that are illustrated with thumbnails from placecage.com $options['calm'] = [ // The label for the option 'label' => 'Nicolas Cage is a calm man', 'attributes' => [ // An image URL in the "data-thumb" attribute 'data-thumb' => 'https://www.placecage.com/260/260', ] ]; $options['crazy'] = [ // The label for the option 'label' => 'Nicolas Cage is a crazy man', 'attributes' => [ // An image URL in the "data-thumb" attribute 'data-thumb' => 'https://www.placecage.com/c/260/260', ] ]; $event->return = $options; } }); Field configuration
      You can define labels for the button, notices, etc, that are used within the inputfield if the defaults don't suit.

       
      https://github.com/Toutouwai/InputfieldSelectImages
      https://processwire.com/modules/inputfield-select-images/
    • By Robin S
      Process Images
      A basic, proof-of-concept Textformatter module for ProcessWire. When the Textformatter is applied to a rich text field it uses Simple HTML DOM to find <img> tags in the field value and passes each img node through a hookable TextformatterProcessImages::processImg() method.
      This is a very simple module that doesn't have any configurable settings and doesn't do anything to the field value unless you hook the TextformatterProcessImages::processImg() method.
      Hook example
      When added to /site/ready.php the hook below will replace any Pageimages in a rich text field with a 250px square variation and wrap the <img> tag in a link to the original full-size image.
      For help with Simple HTML DOM refer to its documentation.
      $wire->addHookAfter('TextformatterProcessImages::processImg', function(HookEvent $event) { // The Simple HTML DOM node for the <img> tag /** @var \simple_html_dom_node $img */ $img = $event->arguments(0); // The Pageimage in the <img> src, if any (will be null for external images) /** @var Pageimage $pageimage */ $pageimage = $event->arguments(1); // The Page object in case you need it /** @var Page $page */ $page = $event->arguments(2); // The Field object in case you need it /** @var Field $field */ $field = $event->arguments(3); // Only for images that have a src corresponding to a PW Pageimage if($pageimage) { // Set the src to a 250x250 variation $img->src = $pageimage->size(250,250)->url; // Wrap the img in a lightbox link to the original $img->outertext = "<a class='lightboxclass' href='{$pageimage->url}'>{$img->outertext}</a>"; } });  
      GitHub: https://github.com/Toutouwai/TextformatterProcessImages
      Modules directory: https://processwire.com/modules/textformatter-process-images/
    • By spercy16
      These issues should be fairly easy for any intermediate to advanced ProcessWire developer to answer. I'm new to PHP and relatively new to ProcessWire and just need a bit of help. What I'm trying to do is bring in a couple of cards from my Projects page to display on my home page. I finally got the code right to bring in the cards but right now they're using my original images instead of my resized "variations". So firstly, I would like to know how to reference the variations of my images instead of using the original. Secondly, I need to grab only four of the cards from the Project page and not import in all ten. It should be just two small changes to my code to do these things (I would imagine). Here is the code I currently have for that section:
      <?php // https://processwire.com/api/arrays/ // check if the array of images has items if (count($pages->get("/projects/")->images)) : // get array of images from the field $images = $pages->get("/projects/")->images; $count = 0; // iterate over each one foreach ($images as $image) : $count++; $sectionText = $pages->get("/projects/")->get("paragraph_$count"); $img = $image; $buttonCode = $pages->get("/projects/")->get("url_$count"); ?> <span id="card<?php echo $count?>" class="card"> <img class="cardThumb" src="<?php echo $img->url; ?>" alt="<?php echo $image->description; ?> Thumbnail" /> <div class="cardBody"> <div class="cardText"> <h2><?php echo $img->description; ?></h2> <?php echo $sectionText; ?> </div> <div class="primaryBtn"> <a href="https://www.paypal.com/donate?hosted_button_id= <?php echo $buttonCode; ?> &source=url"> <button> <i class="fas fa-donate"></i> Donate </button> </a> </div> </div> </span> <?php endforeach; endif; ?> Thanks in advance for any help!
×
×
  • Create New...