Forum

Thread tagged as: Problem, Redactor

Images not uploading via Textarea Editor Redactor

We are having difficulty uploading images via the WYSIWYG textarea editor on our site. I think this was working up until recently and we are not sure why it would suddenly stop.

We use Redactor as the editor on most of the sites we produce and rarely have any issues. I thought it was maybe a version conflict, so I downgraded to v1.1 but the problem persisted.

When you click the "Image" button, the upload dialog box appears and allows you to drop an image or choose a file. It looks like everything is working, but when the upload process is complete, no image appears. I don't see any errors in the console when I inspect either.

The images we are uploading are approx. 200kb and nothing out of the ordinary. I have included the summary info + the Blog Post template below incase there is something obvious we are missing.

Cheers, Alan

SUMMARY INFORMATION

Perch: 2.8.34, PHP: 7.0.17, MySQL: mysqlnd 5.0.12-dev - 20150407 - $Id: b5c5906d452ec590732a93b051f3827e02749b83 $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (2.8.34), assets (2.8.34), categories (2.8.34), perch_blog (5.0), perch_forms (1.8.3)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_forms', 'perch_blog', );
PERCH_LOGINPATH: /perch
PERCH_PATH: /var/www/web/perch
PERCH_CORE: /var/www/web/perch/core
PERCH_RESFILEPATH: /var/www/web/perch/resources
Image manipulation: GD
PHP limits: Max upload 128M, Max POST 128M, Memory: 128M, Total max file upload: 128M
F1: 6a33f95eca3667f9e0c39bf5ca2980fe
Resource folder writeable: Yes
DOCUMENT_ROOT: /var/www/web
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
REQUEST_URI: /perch/core/settings/diagnostics/
HTTP_HOST: www.davidcantwellphotography.com

Template HTML


<section class="gallery"> <div class="row"> <div class="large-10 large-offset-1 port_links"> <div class="row"> <div class="large-9 large-offset-3 columns blog_title"> <p class="pub_date"><perch:blog id="postDateTime" type="date" time="true" format="%d %B %Y" /> </p> <h1><perch:blog id="postTitle" type="text" label="Title" required="true" size="xl autowidth" order="1" /></h1> </div> </div> <div class="row"> <div class="large-9 large-offset-3 columns blog_image"> <img src="<perch:blog id="image" type="image" width="1000" height="750" crop="true" label="Image" order="4" />" alt="<perch:blog id="postTitle" />"> </div> </div> <div class="row"> <div class="large-3 medium-3 columns blog_sidebar hide-for-small-only"> <span class="border"></span> <p>Share this article</p> <!-- SHARE ICONS --> <div class="sharethis-inline-share-buttons"></div> </div> <div class="large-9 medium-9 columns blog_post"> <div class="gallery_wrap"> <perch:repeater id="imgGallery" label="Image Gallery"> <div class="blog_thumb"> <a href="<perch:blog type="image" id="galImg" label="Fullsize Image" width="1440" />" data-lightbox="Book" data-title="<perch:blog type="text" id="imageTitle" label="Image Title" />"> <img src="<perch:blog type="image" id="galImg" width="300" height="300" crop="true" />" alt="<perch:blog type="text" id="imageDesc" label="Image Alt/Description" />"> </a> </div> </perch:repeater> </div> <perch:blog id="postDescHTML" type="textarea" label="Post" order="2" editor="redactor" html="true" size="xxl autowidth" required="true" /> </div> <div class="large-3 columns blog_sidebar show-for-small-only"> <span class="border"></span> <p>Share this article</p> <!-- SHARE ICONS --> <div class="sharethis-inline-share-buttons"></div> </div> </div> </div> </div> </section> <perch:blog id="excerpt" type="textarea" label="Excerpt" markdown="true" order="3" suppress="true" size="s" /> <perch:blog id="image" type="image" width="540" height="400" crop="true" suppress="true" />
Alan McDonnell

Alan McDonnell 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Where did you download the editor from? The supported editor is now for Perch 3 only.

I downloaded the editor from your previous Addons page (before the new design and launch of Perch 3). I got the old version of Redactor today from https://addons.perchcms.com/archive

Rachel Andrew

Rachel Andrew 394 points
Perch Support

Can you upload images via a regular Perch image field?

Yes. That appears to be working normally.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Do you get any errors logged or in your browser console?

Nothing comes up in the console log at all. Very strange.

Drew McLellan

Drew McLellan 2638 points
Perch Support

And nothing in your server log?

There is nothing in the server logs that I can see. I decided to test CKEditor just in case there was an issue with Redactor, but I encountered a similar issue. It returned a message saying the image would not upload to server.

It seems to fail almost immediately and I can't wrap my head around it. I'm thinking it is possibly linked to something on the server side or maybe the version of PHP? It is currently running version 7, although I haven't had issues like this on any of the other sites we are working on.

Drew McLellan

Drew McLellan 2638 points
Perch Support

If your host says everything is ok, then all I can suggest doing is updating to the current version.

I figured it out... after a lot of hair pulling and coffee. The following re-write condition and rule in my HTACCESS file was the culprit:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.php
RewriteRule ^/?(.*)\.php$ /$1 [L,R=301]

I'm surprised it didn't affect anything else - which is probably why it took me so long to get to it. Thanks again for your help. Hopefully if anyone else has a similar issue, the above might help.

^[A-Z]{3,9}\ /([^\ ]+)\.php

Options: Case insensitive; Dot doesn't match line breaks

  • Assert position at the beginning of a line (at beginning of the string or after a line break character) (carriage return and line feed pair, sole line feed, sole carriage return, vertical tab, form feed, next line, line separator, or paragraph separator) ^
  • Match a single character in the range between “A” and “Z” (case insensitive) [A-Z]{3,9}
    • Between 3 and 9 times, as many times as possible, giving back as needed (greedy) {3,9}
  • Match the character “ ” literally \
  • Match the character “/” literally /
  • Match the regex below and capture its match into backreference number 1 ([^\ ]+)
    • Match any character that is NOT a “ ” [^\ ]+
      • Between one and unlimited times, as many times as possible, giving back as needed (greedy) +
  • Match the character “.” literally \.
  • Match the character string “php” literally (case insensitive) php

^/?(.*)\.php$ /$1 [L,R=301]

  • Insert the character string “^/?(.*)” literally ^/?(.*)
  • Insert the backslash character \
  • Insert the character string “.php” literally .php
  • Insert the character “$” literally $
  • Insert the character string “ /” literally /
  • Insert the text that was last matched by capturing group number 1 $1
  • Insert the character string “ [L,R=301]” literally [L,R=301]

Created with RegexBuddy