redactor从剪贴板复制和粘贴图像

I am using Redactor in my website which is based with the Tickets by Dalegroup module from code canyon. I would like to be able to copy and paste images from a clipboard (basically copy a document from word and paste it intact with images) Redactor Settings Page I have attempted to get this to work but I just cannot get it going. I have tried to create my own file upload script:

<?php

$dir = '/knowledge/files/';

$contentType = $_POST['contentType'];
$data = base64_decode($_POST['data']);


$filename = md5(date('YYHis')).'.png';
$file = $dir.$filename;
file_put_contents($file, $data);

echo json_encode(array('filelink' => '/tmp/'.$filename));

?>

this above doesn't seem to work, I have also enabled the functions on their site :

This setting allows to paste images from clipboard and upload them to the server. It     works in latest Chrome, Firefox and Opera (Webkit).

Default setting is true, to turn off, set clipboardUpload: false.

To perform pasted images uploads, set the following:

$('#redactor').redactor({
clipboardUploadUrl: '/your_clipboard_upload_script/'
});

now the only thing I havn't tried is the bottom bit of code there, as the redactor file includes a section with all enabled options so I figured I didn't need it. How is it possible to get this working?

Thanks.

UPDATE:

ok I was able to get the copy and paste working for redactor by enabling and setting a few variables in redactor.js :

dragUpload: true, // false
imageTabLink: true,
imageUpload: '/user/files/', // url
imageUploadParam: 'file', // input name
imageResizable: true,
fileUpload: '/user/files/', // url
fileUploadParam: 'file', // input name
clipboardUpload: true, // or false
clipboardUploadUrl: '/user/files/', // url

then in my html_header.php file for tickets I added the following inside of the $('.wysiwyg_enabled').redactor code starting on Line 69:

clipboardUploadUrl: '/user/files/fileupload.php',
fileUpload: '/user/files/fileupload.php'

Then lastly added my fileupload.php:

<?php

// files storage folder
$dir = '/user/files/';

$_FILES['file']['type'] = strtolower($_FILES['file']['type']);

if ($_FILES['file']['type'] == 'image/png'
|| $_FILES['file']['type'] == 'image/jpg'
|| $_FILES['file']['type'] == 'image/gif'
|| $_FILES['file']['type'] == 'image/jpeg'
|| $_FILES['file']['type'] == 'image/pjpeg')
{
// setting file's mysterious name
$file = $dir.md5(date('YmdHis')).'.jpg';

// copying
move_uploaded_file($_FILES['file']['tmp_name'], $file);

// displaying file
$array = array(
    'filelink' => '/user/images/'.$file
);

echo stripslashes(json_encode($array));
}

?>

Everything seems to work but I get an error in chrome: Uncaught SyntaxError: Unexpected end of input. it's not in my code but in Jquery itself. The copy and paste works great in Mozilla, not IE and sometimes in Chrome due to the error.

It might not help - i'm trying to do the same thing at the moment - but here's a redactor bundle working: https://github.com/kraksoft/RedactorBundle I'm actually using it (i forked the project too but did not bring anything new to it), and image upload works, and i think i'm not too far from making the clipboard upload work, stay updated on the bundle !