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


PHP file::register_upload方法代码示例

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


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

示例1: file

                     $file = new file();
                     $file->load($_REQUEST['id']);
                     $file->refresh();
                     $DB->disconnect();
                     core_terminate();
                 }
             }
         }
     }
     echo false;
     core_terminate();
 } else {
     if ($_REQUEST['engine'] == 'tinymce') {
         $DB = new database();
         $DB->connect();
         $file = file::register_upload($_FILES['file']['tmp_name'], $_FILES['file']['name'], 0, NULL, true);
         if (!empty($file)) {
             echo json_encode(array('location' => file::file_url($file->id)));
         } else {
             echo json_encode(false);
         }
         $DB->disconnect();
         core_terminate();
     } else {
         // plUpload engine
         if ($user->permission("files.upload") == "true") {
             // Get parameters
             $chunk = isset($_REQUEST["chunk"]) ? $_REQUEST["chunk"] : 0;
             $chunks = isset($_REQUEST["chunks"]) ? $_REQUEST["chunks"] : 0;
             $fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : '';
             // Clean the fileName for security reasons
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:31,代码来源:navigate_upload.php

示例2: metaWeblog_newMediaObject

 function metaWeblog_newMediaObject($args)
 {
     global $DB;
     global $session;
     $out = array();
     list($website_id, $username, $password, $file_struct) = $args;
     // check auth
     if (metaWeblog_userAllowed($username, $password, $website_id)) {
         $file_name_tmp = uniqid('metaweblog-upload-');
         file_put_contents(NAVIGATE_PRIVATE . '/' . $website_id . '/files/' . $file_name_tmp, $file_struct['bits']);
         $file = file::register_upload($file_name_tmp, $file_struct['name'], 0, NULL, false);
         @unlink(AVIGATE_PRIVATE . '/' . $website_id . '/files/' . $file_name_tmp);
         // if everything goes fine, file is renamed, so cannot be deleted here
         $out = array('id' => $file->id, 'file' => $file->name, 'url' => file::file_url($file->id, 'inline'), 'type' => $file->mime);
     } else {
         $out = new IXR_Error(401, "User not allowed.");
     }
     return $out;
 }
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:19,代码来源:nvweb_xmlrpc.php

示例3: run

function run()
{
    global $user;
    global $layout;
    global $DB;
    global $website;
    $out = '';
    $item = new file();
    switch ($_REQUEST['act']) {
        case 1:
            // json retrieval & operations
        // json retrieval & operations
        case "json":
            if ($_REQUEST['op'] == 'upload') {
                $tmp_name = $_REQUEST['tmp_name'];
                if ($tmp_name == "{{BASE64}}") {
                    $tmp_name = base64_encode($_REQUEST['name']);
                }
                $file = file::register_upload($tmp_name, $_REQUEST['name'], $_REQUEST['parent']);
                if (!empty($file)) {
                    echo json_encode(array('id' => $file->id, 'name' => $file->name));
                } else {
                    echo json_encode(false);
                }
            }
            switch ($_REQUEST['op']) {
                case 'create_folder':
                    file::create_folder($_REQUEST['name'], $_REQUEST['mime'], $_REQUEST['parent']);
                    echo json_encode(true);
                    break;
                case 'edit_folder':
                    $f = new file();
                    $f->load(intval($_REQUEST['id']));
                    $f->name = $_REQUEST['name'];
                    $f->mime = $_REQUEST['mime'];
                    $ok = $f->save();
                    echo json_encode($ok);
                    break;
                case 'edit_file':
                    $f = new file();
                    $f->load(intval($_REQUEST['id']));
                    $f->name = $_REQUEST['name'];
                    $ok = $f->save();
                    echo json_encode($ok);
                    break;
                case 'duplicate_file':
                    //error_reporting(~0);
                    //ini_set('display_errors', 1);
                    $status = false;
                    $f = new file();
                    $f->load(intval($_REQUEST['id']));
                    $f->id = 0;
                    $f->insert();
                    if (!empty($f->id)) {
                        $done = copy(NAVIGATE_PRIVATE . '/' . $website->id . '/files/' . intval($_REQUEST['id']), NAVIGATE_PRIVATE . '/' . $website->id . '/files/' . $f->id);
                        $status = "true";
                        if (!$done) {
                            $f->delete();
                            $status = t(56, "Unexpected error");
                        }
                    }
                    echo $status;
                    break;
                case 'move':
                    if (is_array($_REQUEST['item'])) {
                        $ok = true;
                        for ($i = 0; $i < count($_REQUEST['item']); $i++) {
                            unset($item);
                            $item = new file();
                            $item->load($_REQUEST['item'][$i]);
                            $item->parent = $_REQUEST['folder'];
                            $ok = $ok & $item->update();
                        }
                        echo json_encode($ok ? true : false);
                    } else {
                        $item->load($_REQUEST['item']);
                        $item->parent = $_REQUEST['folder'];
                        echo json_encode($item->update());
                    }
                    break;
                case 'delete':
                    try {
                        $item->load($_REQUEST['id']);
                        $status = $item->delete();
                        echo json_encode($status);
                    } catch (Exception $e) {
                        echo $e->getMessage();
                    }
                    break;
                case 'permissions':
                    $item->load($_REQUEST['id']);
                    if (!empty($_POST)) {
                        $item->access = intval($_POST['access']);
                        $item->permission = intval($_POST['permission']);
                        $item->enabled = intval($_POST['enabled']);
                        $item->groups = $_POST['groups'];
                        if ($item->access < 3) {
                            $item->groups = array();
                        }
                        $status = $item->save();
//.........这里部分代码省略.........
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:101,代码来源:files.php


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