當前位置: 首頁>>代碼示例>>PHP>>正文


PHP upload::init方法代碼示例

本文整理匯總了PHP中upload::init方法的典型用法代碼示例。如果您正苦於以下問題:PHP upload::init方法的具體用法?PHP upload::init怎麽用?PHP upload::init使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在upload的用法示例。


在下文中一共展示了upload::init方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: upload

 function upload($file)
 {
     global $_G;
     if (!class_exists('upload')) {
         include ROOT_PATH . 'web/upload.class.php';
     }
     if (!is_array($file)) {
         $file = $this->file;
     }
     $upload = new upload();
     $img_arr = $attach = array();
     $upload_path = '/assets/uploads/';
     $rs = $upload->init($file, $upload_path);
     if (!$rs) {
         return false;
     }
     $attach =& $upload->attach;
     if ($attach['extension'] != 'jpg' && $attach['extension'] != 'png') {
         $this->file_type = '.' . $attach['extension'];
         $this->__construct();
     }
     if ($attach['extension'] == 'attach' && $attach['isimage'] != 1) {
         $this->msg = '上傳的文件非圖片';
         L($this->msg);
         @unlink($attach['tmp_name']);
         return false;
         //非可上傳的文件,就禁止上傳了
     }
     $upload_max_size = $_G['setting']['upload_max_size'] ? intval($_G['setting']['upload_max_size']) : 2;
     if ($attach['size'] > 1024 * 1024 * $upload_max_size) {
         $this->msg = '上傳文件失敗,係統設置最大上傳大為:' . $upload_max_size . 'MB';
         L($this->msg);
         @unlink($attach['tmp_name']);
         return false;
     }
     if ($attach['errorcode']) {
         $this->msg = '上傳圖片失敗' . errormessage();
         @unlink($attach['tmp_name']);
         L($this->msg);
         return false;
     }
     $lang_path = ROOT_PATH . $upload_path . $this->dir2;
     if (!is_dir($lang_path)) {
         dmkdir($lang_path);
     }
     $attach['target'] = $lang_path . $this->name;
     $upload->save();
     return $upload_path . $this->dir2 . $this->name;
 }
開發者ID:sayi21cn,項目名稱:ttae_open,代碼行數:49,代碼來源:web_upload.php

示例2: init

 function init()
 {
     parent::init();
     // Array list of allowed extensions
     $this->ext_check = array();
 }
開發者ID:visavi,項目名稱:rotorcms4,代碼行數:6,代碼來源:FileUpload.php

示例3: isset

$action = isset($_GET['action']) ? $_GET['action'] : '';
if ($action == 'add' || $action == 'status' || $action == 'cancel') {
    if (!$sustc->user->islogin()) {
        dredirect('/user/signin?redirect=/print/' . $action);
    }
}
if ($action == 'add') {
    $err = array('code' => 0);
    if (is_post()) {
        $err['code'] = -1;
        if (isset($_POST['formhash']) && $sustc->security->check_formhash($_POST['formhash'])) {
            if (isset($_POST['print'])) {
                global $_G;
                $print = $_POST['print'];
                $upload = new upload();
                if (isset($_FILES['document']) && $upload->init($_FILES['document'], 'document')) {
                    if ($upload->save(1)) {
                        $node_id = intval($print['node']);
                        //check node_id $cloudprint->nodes
                        //if ($node_id != 1)
                        $queue = array('uid' => $_G['uid'], 'node_id' => $node_id, 'document_id' => $upload->attid, 'duplex' => $print['duplex'] ? true : false, 'colorful' => intval($print['colorful']) ? true : false, 'copies' => intval($print['copies']), 'status' => 0, 'starttime' => TIMESTAMP);
                        if ($queue['copies'] > 0) {
                            $queue_id = DB::insert('print_queue', $queue, true);
                            if ($queue_id > 0) {
                                dredirect('/print/status/' . $queue_id);
                            }
                        }
                    }
                }
            }
        }
開發者ID:huiwei19,項目名稱:oursustc-php,代碼行數:31,代碼來源:index.php


注:本文中的upload::init方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。