当前位置: 首页>>代码示例>>PHP>>正文


PHP DocumentManager::upload_document方法代码示例

本文整理汇总了PHP中DocumentManager::upload_document方法的典型用法代码示例。如果您正苦于以下问题:PHP DocumentManager::upload_document方法的具体用法?PHP DocumentManager::upload_document怎么用?PHP DocumentManager::upload_document使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DocumentManager的用法示例。


在下文中一共展示了DocumentManager::upload_document方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

$file = array(
    'file' => array(
        'name' => $fileInfo['basename'],
        'tmp_name' => $documentPath,
        'size' => filesize($documentPath),
        'from_file' => true
    )
);
$output = true;
ob_start();
$documentData = DocumentManager::upload_document(
    $file,
    $wamidir,
    $fileInfo['basename'],
    'wav',
    0,
    'overwrite',
    false,
    $output
);
$contents = ob_get_contents();

if (!empty($documentData)) {
    $newDocId = $documentData['id'];
    $documentData['comment'] = 'mp3';
    $newMp3DocumentId = DocumentManager::addAndConvertWavToMp3(
        $documentData,
        $courseInfo,
        api_get_session_id(),
        api_get_user_id(),
        'overwrite',
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:31,代码来源:record_document.php

示例2: api_is_allowed_to_edit

     $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
     // This needs cleaning!
     if (api_get_group_id()) {
         if ($is_allowed_to_edit || GroupManager::is_user_in_group(api_get_user_id(), api_get_group_id())) {
             // Only courseadmin or group members allowed
         } else {
             exit;
         }
     } elseif ($is_allowed_to_edit || is_my_shared_folder(api_get_user_id(), $_POST['curdirpath'], api_get_session_id())) {
     } else {
         // No course admin and no group member...
         exit;
     }
     if (!empty($_FILES)) {
         $file = $_FILES['file'];
         $result = DocumentManager::upload_document($_FILES, $_POST['curdirpath'], $file['name'], null, 0, 'overwrite', false, false);
         $json = array();
         $json['name'] = Display::url(api_htmlentities($file['name']), api_htmlentities($result['url']), array('target' => '_blank'));
         $json['type'] = api_htmlentities($file['type']);
         $json['size'] = Text::format_file_size($file['size']);
         if (!empty($result) && is_array($result)) {
             $json['result'] = Display::return_icon('accept.png', get_lang('Uploaded'));
         } else {
             $json['result'] = Display::return_icon('exclamation.png', get_lang('Error'));
         }
         echo json_encode($json);
     }
     break;
 case 'document_preview':
     $course_info = api_get_course_info_by_id($_REQUEST['course_id']);
     if (!empty($course_info) && is_array($course_info)) {
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:31,代码来源:document.ajax.php

示例3: array

        $dir,
        '/'.$folderName,
        $folderName
    );
    if ($createdDir) {
        $path = '/'.$folderName;
    }
} else {
    $data = DocumentManager::get_document_data_by_id($documentId, $courseInfo['code']);
    $path = $data['path'];
}

if (empty($path)) {
    exit;
}

$files = array(
    'file' => $_FILES['Filedata']
);

DocumentManager::upload_document(
    $files,
    $path,
    $_FILES['Filedata']['name'],
    null,
    false,
    'rename',
    false,
    true
);
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:30,代码来源:upload.php

示例4: api_not_allowed

if (!isset($_GET['filename']) || !isset($_GET['file_field'])) {
    api_not_allowed(false);
    exit;
}

$courseInfo = api_get_course_info();

$fileUpload = null;
if (is_uploaded_file($_FILES[$_GET['file_field']]['tmp_name'])) {
    $fileUpload = $_FILES[$_GET['file_field']];
} else {
    exit;
}

$output = false;
$documentData = DocumentManager::upload_document($_FILES, $_GET['path'], null, null, 0, 'overwrite', false, $output);

if (!empty($documentData)) {
    $newDocId = $documentData['id'];
    $newMp3DocumentId = DocumentManager::addAndConvertWavToMp3(
        $documentData,
        $courseInfo,
        api_get_session_id(),
        api_get_user_id(),
        'overwrite',
        true
    );

    if ($newMp3DocumentId) {
        $newDocId = $newMp3DocumentId;
    }
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:31,代码来源:upload_nanogong_file.php

示例5: add_audio

 function add_audio()
 {
     $course_info = api_get_course_info();
     $filepath = api_get_path(SYS_COURSE_PATH) . $course_info['path'] . '/document/';
     if (!is_dir($filepath . 'audio')) {
         mkdir($filepath . 'audio', api_get_permissions_for_new_directories());
         $audio_id = FileManager::add_document($course_info, '/audio', 'folder', 0, 'audio');
         api_item_property_update($course_info, TOOL_DOCUMENT, $audio_id, 'FolderCreated', api_get_user_id(), null, null, null, null, api_get_session_id());
         api_item_property_update($course_info, TOOL_DOCUMENT, $audio_id, 'invisible', api_get_user_id(), null, null, null, null, api_get_session_id());
     }
     $key = 'file';
     if (!isset($_FILES[$key]['name']) || !isset($_FILES[$key]['tmp_name'])) {
         return false;
     }
     $result = DocumentManager::upload_document($_FILES, '/audio', null, null, 0, 'rename', false, false);
     $file_path = null;
     if ($result) {
         $file_path = basename($result['path']);
         // Store the mp3 file in the lp_item table.
         $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
         $sql_insert_audio = "UPDATE {$tbl_lp_item} SET audio = '" . Database::escape_string($file_path) . "'\n                                WHERE c_id = {$course_info['real_id']} AND id = '" . Database::escape_string($this->db_id) . "'";
         Database::query($sql_insert_audio);
     }
     return $file_path;
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:25,代码来源:learnpathItem.class.php

示例6: api_get_path

     if (empty($lpPathInfo)) {
         exit;
     }
     require_once api_get_path(LIBRARY_PATH) . 'fileDisplay.lib.php';
     require_once api_get_path(LIBRARY_PATH) . 'document.lib.php';
     require_once api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php';
     foreach (array('video', 'audio') as $type) {
         if (isset($_FILES["{$type}-blob"])) {
             $fileName = $_POST["{$type}-filename"];
             //$file = $_FILES["${type}-blob"]["tmp_name"];
             $file = $_FILES["{$type}-blob"];
             $fileInfo = pathinfo($fileName);
             $file['name'] = 'rec_' . date('Y-m-d_His') . '_' . uniqid() . '.' . $fileInfo['extension'];
             $file['file'] = $file;
             $lpPathInfo['dir'] = api_remove_trailing_slash($lpPathInfo['dir']);
             $result = DocumentManager::upload_document($file, $lpPathInfo['dir'], $file['name'], null, 0, 'overwrite', false, false);
             if (!empty($result) && is_array($result)) {
                 $newDocId = $result['id'];
                 $courseId = $result['c_id'];
                 $lp->set_modified_on();
                 $lpItem = new learnpathItem($_REQUEST['lp_item_id']);
                 $lpItem->add_audio_from_documents($newDocId);
                 $data = DocumentManager::get_document_data_by_id($newDocId, $course_info['code']);
                 echo $data['document_url'];
                 exit;
             }
         }
     }
     break;
 default:
     echo '';
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:31,代码来源:lp.ajax.php

示例7: array

if (empty($document_data['parents'])) {
    $interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']);
} else {
    foreach ($document_data['parents'] as $document_sub_data) {
        $interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']);
    }
}
$this_section = SECTION_COURSES;
// Display the header
Display::display_header($nameTools, 'Doc');
/*    Here we do all the work */
$unzip = isset($_POST['unzip']) ? $_POST['unzip'] : null;
$index = isset($_POST['index_document']) ? $_POST['index_document'] : null;
// User has submitted a file
if (!empty($_FILES)) {
    DocumentManager::upload_document($_FILES, $_POST['curdirpath'], $_POST['title'], $_POST['comment'], $unzip, $_POST['if_exists'], $index, true);
}
// Actions
// Link back to the documents overview
if ($is_certificate_mode) {
    $actions = '<a href="document.php?id=' . $document_id . '&selectcat=' . $selectcat . '&' . api_get_cidreq() . '">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('CertificateOverview'), '', ICON_SIZE_MEDIUM) . '</a>';
} else {
    $actions = '<a href="document.php?id=' . $document_id . '&' . api_get_cidreq() . '">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM) . '</a>';
}
// Link to create a folder
echo $toolbar = Display::toolbarAction('toolbar-upload', array(0 => $actions), 1);
// Form to select directory
$folders = DocumentManager::get_all_document_folders($_course, $groupId, $is_allowed_to_edit);
if (!$is_certificate_mode) {
    echo DocumentManager::build_directory_selector($folders, $document_id, isset($group_properties['directory']) ? $group_properties['directory'] : array());
}
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:31,代码来源:upload.php

示例8: unlink

if (!DocumentManager::enough_space(filesize($tmpfname), DocumentManager::get_course_quota())) {
    unlink($tmpfname);
    die(get_lang('UplNotEnoughSpace'));
}
//erase temporal file
unlink($tmpfname);
// Add to disk
$fh = fopen($documentPath, 'w') or die("can't open file");
fwrite($fh, $content);
fclose($fh);
error_log($documentPath);
$fileInfo = pathinfo($documentPath);
$courseInfo = api_get_course_info();
$file = array('file' => array('name' => $fileInfo['basename'], 'tmp_name' => $documentPath, 'size' => filesize($documentPath), 'from_file' => true));
$output = true;
$documentData = DocumentManager::upload_document($file, $wamidir, null, null, 0, 'overwrite', false, $output);
if (!empty($documentData)) {
    $newDocId = $documentData['id'];
    $newMp3DocumentId = DocumentManager::addAndConvertWavToMp3($documentData, $courseInfo, api_get_user_id());
    if ($newMp3DocumentId) {
        $newDocId = $newMp3DocumentId;
    }
    if (isset($_REQUEST['lp_item_id']) && !empty($_REQUEST['lp_item_id'])) {
        $lpItemId = $_REQUEST['lp_item_id'];
        /** @var learnpath $lp */
        $lp = isset($_SESSION['oLP']) ? $_SESSION['oLP'] : null;
        if (!empty($lp)) {
            $lp->set_modified_on();
            $lpItem = new learnpathItem($lpItemId);
            $lpItem->add_audio_from_documents($newDocId);
        }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:31,代码来源:record_document.php

示例9: foreach

 //$ifExists = isset($_POST['if_exists']) ? $_POST['if_exists'] : $defaultFileExistsOption;
 if (!empty($_FILES)) {
     $files = $_FILES['files'];
     $fileList = [];
     foreach ($files as $name => $array) {
         $counter = 0;
         foreach ($array as $data) {
             $fileList[$counter][$name] = $data;
             $counter++;
         }
     }
     $resultList = [];
     foreach ($fileList as $file) {
         $globalFile = [];
         $globalFile['files'] = $file;
         $result = DocumentManager::upload_document($globalFile, $_REQUEST['curdirpath'], $file['name'], '', 0, $defaultFileExistsOption, false, false, 'files');
         $json = array();
         $json['name'] = Display::url(api_htmlentities($result['title']), api_htmlentities($result['url']), array('target' => '_blank'));
         $json['url'] = $result['url'];
         $json['size'] = format_file_size($file['size']);
         $json['type'] = api_htmlentities($file['type']);
         if (!empty($result) && is_array($result)) {
             $json['result'] = Display::return_icon('accept.png', get_lang('Uploaded'));
         } else {
             $json['result'] = Display::return_icon('exclamation.png', get_lang('Error'));
         }
         $resultList[] = $json;
     }
     echo json_encode(['files' => $resultList]);
 }
 exit;
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:document.ajax.php

示例10: elseif

             exit;
         }
     } elseif ($is_allowed_to_edit || DocumentManager::is_my_shared_folder(api_get_user_id(), $_POST['curdirpath'], api_get_session_id())) {
     } else {
         // No course admin and no group member...
         exit;
     }
     $fileExistsOption = api_get_setting('document_if_file_exists_option');
     $defaultFileExistsOption = 'rename';
     if (!empty($fileExistsOption)) {
         $defaultFileExistsOption = $fileExistsOption;
     }
     //$ifExists = isset($_POST['if_exists']) ? $_POST['if_exists'] : $defaultFileExistsOption;
     if (!empty($_FILES)) {
         $file = $_FILES['file'];
         $result = DocumentManager::upload_document($_FILES, $_POST['curdirpath'], $file['name'], '', 0, $defaultFileExistsOption, false, false);
         $json = array();
         $json['name'] = Display::url(api_htmlentities($result['title']), api_htmlentities($result['url']), array('target' => '_blank'));
         $json['type'] = api_htmlentities($file['type']);
         $json['size'] = format_file_size($file['size']);
         if (!empty($result) && is_array($result)) {
             $json['result'] = Display::return_icon('accept.png', get_lang('Uploaded'));
         } else {
             $json['result'] = Display::return_icon('exclamation.png', get_lang('Error'));
         }
         echo json_encode($json);
     }
     break;
 case 'document_preview':
     $course_info = api_get_course_info_by_id($_REQUEST['course_id']);
     if (!empty($course_info) && is_array($course_info)) {
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:31,代码来源:document.ajax.php

示例11: foreach

 }
 if (!empty($_FILES)) {
     $files = $_FILES['files'];
     $fileList = [];
     foreach ($files as $name => $array) {
         $counter = 0;
         foreach ($array as $data) {
             $fileList[$counter][$name] = $data;
             $counter++;
         }
     }
     $resultList = [];
     foreach ($fileList as $file) {
         $globalFile = [];
         $globalFile['files'] = $file;
         $result = DocumentManager::upload_document($globalFile, $currentDirectory, $file['name'], '', $unzip, $defaultFileExistsOption, false, false, 'files');
         $json = array();
         if (!empty($result) && is_array($result)) {
             $json['name'] = Display::url(api_htmlentities($result['title']), api_htmlentities($result['url']), array('target' => '_blank'));
             $json['url'] = $result['url'];
             $json['size'] = format_file_size($file['size']);
             $json['type'] = api_htmlentities($file['type']);
             $json['result'] = Display::return_icon('accept.png', get_lang('Uploaded'));
         } else {
             $json['url'] = '';
             $json['error'] = get_lang('Error');
         }
         $resultList[] = $json;
     }
     echo json_encode(['files' => $resultList]);
 }
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:31,代码来源:document.ajax.php


注:本文中的DocumentManager::upload_document方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。