Ejemplo n.º 1
0
function uploadCK($page, $identifier, $obj)
{
    $funcNum2 = get_Input('CKEditorFuncNum', 'CKEditorFuncNum');
    $file = new ElggFile();
    $filestorename = strtolower(time() . $_FILES['upload']['name']);
    $file->setFilename($filestorename);
    $file->setMimeType($_FILES['upload']['type']);
    $file->owner_guid = elgg_get_logged_in_user_guid();
    $file->subtype = "file";
    $file->originalfilename = $filestorename;
    $file->access_id = ACCESS_PUBLIC;
    $file->open("write");
    $file->write(get_uploaded_file('upload'));
    $file->close();
    $result = $file->save();
    if ($result) {
        $master = get_resized_image_from_existing_file($file->getFilenameOnFilestore(), 550, 550);
        if ($master !== false) {
            $_SESSION['UPLOAD_DATA']['file_save'] = "started";
            $filehandler = new ElggFile();
            $filehandler->setFilename($filestorename);
            $filehandler->setMimeType($_FILES['upload']['type']);
            $filehandler->owner_guid = $user->guid;
            $filehandler->subtype = "file";
            $filehandler->originalfilename = $filestorename;
            $filehandler->access_id = ACCESS_PUBLIC;
            $filehandler->open("write");
            $filehandler->write($master);
            $filehandler->close();
            $filehandler->save();
            // Dev URL
            $url = elgg_get_site_url() . 'CKEditorView?file_guid=' . $filehandler->guid;
            //Production URL
            //$url ='/CKEditorView?file_guid='.$filehandler->guid;
            echo '<script type="text/javascript">
		window.parent.CKEDITOR.tools.callFunction(' . $funcNum2 . ', "' . $url . '","");
		</script>';
            exit;
        } else {
            echo '<script type="text/javascript">
		window.parent.CKEDITOR.tools.callFunction(' . $funcNum2 . ', "","");
		</script>';
            exit;
        }
    }
    return true;
}
<?php

global $CONFIG;
$user = get_loggedin_user();
$funcNum2 = get_Input('CKEditorFuncNum', 'CKEditorFuncNum');
$file = new ElggFile();
$filestorename = strtolower(time() . $_FILES['upload']['name']);
$file->setFilename($filestorename);
$file->setMimeType($_FILES['upload']['type']);
$file->owner_guid = $user->guid;
$file->subtype = "file";
$file->originalfilename = $filestorename;
$file->access_id = ACCESS_DEFAULT;
$file->open("write");
$file->write(get_uploaded_file('upload'));
$file->close();
$result = $file->save();
if ($result) {
    $master = get_resized_image_from_existing_file($file->getFilenameOnFilestore(), 550, 550);
    if ($master !== false) {
        $_SESSION['UPLOAD_DATA']['file_save'] = "started";
        $filehandler = new ElggFile();
        $filehandler->setFilename($filestorename);
        $filehandler->setMimeType($_FILES['upload']['type']);
        $filehandler->owner_guid = $user->guid;
        $filehandler->subtype = "file";
        $filehandler->originalfilename = $filestorename;
        $filehandler->access_id = ACCESS_DEFAULT;
        $filehandler->open("write");
        $filehandler->write($master);
        $filehandler->close();