$upload = new eZContentUpload();
        $upload->handleUpload($result, 'Filedata', $parentNodeID, false);
    }
    // Exec multiupload handlers postUpload method
    eZMultiuploadHandler::exec('postUpload', $result);
    // Pass result to template and process it
    $tpl->setVariable('result', $result);
    $templateOutput = $tpl->fetch('design:ezmultiupload/thumbnail.tpl');
    // Strip all new lines from processed template and convert all applicable characters to
    // HTML entities output. Create upload ID
    $httpCharset = eZTextCodec::httpCharset();
    $data = htmlentities(str_replace(array("\r\n", "\r", "\n"), array(""), $templateOutput), ENT_QUOTES, $httpCharset);
    $id = md5((string) mt_rand() . (string) microtime());
    $response = array('data' => $data, 'id' => $id);
    // Return server response in JSON format
    echo eZAjaxContent::jsonEncode($response);
    // Stop execution
    eZExecution::cleanExit();
} else {
    // Check if parent node ID provided in URL exists and is an integer
    if (!$parentNodeID || !is_numeric($parentNodeID)) {
        return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
    }
    // Fetch parent node
    $parentNode = eZContentObjectTreeNode::fetch($parentNodeID);
    // Check if parent node object exists
    if (!$parentNode) {
        return $module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
    }
    // Check if current user has access to parent node and can create content inside
    if (!$parentNode->attribute('can_read') || !$parentNode->attribute('can_create')) {
 /**
  * Wrapper function for encoding to json with native or php version
  * depending on what the system supports
  * 
  * @param mixed $obj
  * @return string
  */
 public static function jsonEncode($obj)
 {
     if (self::$nativeJsonEncode === null) {
         self::$nativeJsonEncode = function_exists('json_encode');
     }
     if (self::$nativeJsonEncode === true) {
         return json_encode($obj);
     }
     $inst = self::getInstance();
     return $inst->phpJsonEncode($obj);
 }