CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Unable to upload images via KCFinder - get "Unknown error"
Pages: [1]

Author Topic: Unable to upload images via KCFinder - get "Unknown error"  (Read 12668 times)

Patricia43

  • I post occasionally
  • **
  • Posts: 50
  • Karma: 1
  • CiviCRM version: 4.0
  • CMS version: Drupal 7
  • MySQL version: 5.1
  • PHP version: 5.3
Unable to upload images via KCFinder - get "Unknown error"
November 24, 2012, 09:10:04 am
I have one site where I can upload images without difficulty but I am now trying to configure CiviCRM on another site and am having difficulties with image upload.

Originally I couldn't see the images I had uploaded earlier via Drupal. Then I changed the uploadDir and uploadURL to point to the image directory that I use for Drupal. I was very excited when I could see the images I had already uploaded (in Drupal) to that directory and can select them to insert into my messages. However, if I attempt to upload a new image I get an Uploading file ... alert followed by an "Unknown error" popup window.

Any ideas what causes this error?

Patricia43

  • I post occasionally
  • **
  • Posts: 50
  • Karma: 1
  • CiviCRM version: 4.0
  • CMS version: Drupal 7
  • MySQL version: 5.1
  • PHP version: 5.3
Re: Unable to upload images via KCFinder - get "Unknown error"
November 24, 2012, 01:07:02 pm
I've narrowed down the problem. It is happening in protected function checkUploadedFile in the KCFinder uploader.php.

The following code is generating the error message:

if (!is_array($file) || !isset($file['name']))
            return $this->label("Unknown error");

I have very limited knowledge of PHP but I think this error happens when either $file is empty or 'name" is empty.

This function is called in public function upload without any parameters being passed:

if ($config['disabled'] || !$config['access']['files']['upload']) {
            if (isset($file['tmp_name'])) @unlink($file['tmp_name']);
            $message = $this->label("You don't have permissions to upload files.");

        } elseif (true === ($message = $this->checkUploadedFile()))

Would this cause the error? If so why?

If since found that the problem may because the second element in $_FILES is null (and maybe due to PHP version being 5.3.18
 
array(2)    {
      ["upload"]=>array(5)    {
                     ["name"]=>array(1)    {[0]=>string(26) "my image.png"}
                     ["type"]=>array(1)    {[0]=>string(9) "image/png"}
                     ["tmp_name"]=>array(1)    {[0]=>string(14) "/tmp/phpLpXqon"}
                     ["error"]=>array(1)    {[0]=>int(0)}
                     ["size"]=>array(1)    {[0]=>int(16472)}
                     }
         [""]=>&NULL
         }
« Last Edit: November 26, 2012, 09:26:06 am by Patricia43 »

Patricia43

  • I post occasionally
  • **
  • Posts: 50
  • Karma: 1
  • CiviCRM version: 4.0
  • CMS version: Drupal 7
  • MySQL version: 5.1
  • PHP version: 5.3
Re: Unable to upload images via KCFinder - get "Unknown error"
November 26, 2012, 12:43:58 pm
I have no idea what happened but after hacking around I messed things up so much I restored uploader.php and modified config.php to point to the Drupal director and everything is working correctly now.

markimus

  • I post occasionally
  • **
  • Posts: 75
  • Karma: 0
Re: Unable to upload images via KCFinder - get "Unknown error"
December 10, 2012, 01:42:27 pm
Where in your config file did you point to the drupal directory? 
Success is the ability to go from one failure to another with no loss of enthusiasm.

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Unable to upload images via KCFinder - get "Unknown error"
January 08, 2013, 10:15:11 am
I am having the exact same problem.  The function "checkUploadedFile" is getting called with an empty parm and therefore the upload fails with the message ""Unknown error"

This is under Drupal7 + CiviCRM 4.2.7

I have already added some logging code to the file  civicrm/packages/kcfinder/core/uploader.php  but that did not shed any light on the issue, other than confirming the parameter is empty.  Any ideas on what I should investigate next?
« Last Edit: January 08, 2013, 11:01:39 am by epg »
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

jaapjansma

  • I post frequently
  • ***
  • Posts: 247
  • Karma: 9
    • CiviCoop
  • CiviCRM version: 4.4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.4
Re: Unable to upload images via KCFinder - get "Unknown error"
October 02, 2013, 05:35:32 am
I have got a similair problem on a site today. The config.php from the KCFinder did not get included. Renaming the file to config_new.php and also changing the kcfinder code to include the config_new.php did the trick.

Does anyone have similair problems? This happends on CiviCrm 4.3.5 and Drupal 7.
Developer at Edeveloper / CiviCoop

ankles

  • I’m new here
  • *
  • Posts: 6
  • Karma: 0
  • MySQL version: ?
  • PHP version: ?
Re: Unable to upload images via KCFinder - get "Unknown error"
January 15, 2014, 09:03:04 am
I've got this error on CiviCRM 4.3.5 and Drupal 7.24. I tried adding the code as suggested on issues.civicrm.org but it didn't fix it. Did anyone else manage to get it working another way? I didn't really understand why or how the suggestion of renaming the config file would work as jaapjansma said in the previous post.


The solution is to change code in the file "packages/kcfinder/core/uploader.php"

Around line 125, remove the following section of code:
// LINKING UPLOADED FILE
         if (count($_FILES))
             $this->file = &$_FILES[key($_FILES)];


Replace that code with the following new code:
// LINKING UPLOADED FILE
         if (count($_FILES)) {
           foreach($_FILES as $key => $value) {
             if($key)
               $this->file = &$_FILES[key($_FILES)];
           }
         }


http://issues.civicrm.org/jira/browse/CRM-12975

friendswoodtech

  • I’m new here
  • *
  • Posts: 28
  • Karma: 1
  • CiviCRM version: 4.5.5
  • CMS version: Drupal 7
  • MySQL version: 5.1.56
  • PHP version: 5.3.6
Re: Unable to upload images via KCFinder - get "Unknown error"
November 12, 2014, 11:52:54 am
This one has been plaguing me for some time on one of my sites.  This site was setup so long ago, that I never even thought to look at my civi configs.  Symptoms were that I was unable to Upload and Send to Server - I would get an unknown error.  However, I could Browse Server and upload there without issue.  Going through the configs step by step showed that I had discrepancies in my Resource URLs and Directories in civi config and that my baseurl in the civi settings file was not entered with the www.  Once I added and updated Resource URLs and Directories, all began to work.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Unable to upload images via KCFinder - get "Unknown error"

This forum was archived on 2017-11-26.