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


PHP Attachments::getInstance方法代码示例

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


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

示例1: upload_process

 function upload_process($type_id = '0')
 {
     $attach_info = array();
     //init moved here
     if (empty($this->upload_dir)) {
         $this->upload_dir = gmdate("Y") . DS . gmdate("m") . DS . gmdate("d");
     }
     $this->out_file_path = PHPB2B_ROOT . $this->attachment_dir . DS . $this->upload_dir . DS;
     $this->upload_url = str_replace(array(DS, "\\", "\\'"), "/", $this->upload_dir) . '/';
     if (isset($_FILES) && $_FILES[$this->upload_form_field]['size'] > 0) {
         $mimetype = new mimetype();
         $file_ext = strtolower(fileext($_FILES[$this->upload_form_field]['name']));
         if ($this->is_image) {
             //check image format
             if (!in_array($file_ext, $this->imgext)) {
                 return L("format_not_support");
             }
         }
         if (in_array($file_ext, $this->imgext)) {
             $this->is_image = 1;
             $this->allowed_file_ext = $this->imgext;
             if (!in_array($_FILES[$this->upload_form_field]['type'], $mimetype->image_mimes)) {
                 flash("format_not_support", '', 0);
             }
         }
         require LIB_PATH . "upload.class.php";
         $upload = new FileUploads();
         $upload->upload_dir = $this->out_file_path;
         $upload->extensions = $this->allowed_file_ext;
         $upload->max_file_size = $this->max_file_size;
         $upload->the_temp_file = $_FILES[$this->upload_form_field]['tmp_name'];
         $upload->the_file = $_FILES[$this->upload_form_field]['name'];
         $upload->http_error = $_FILES[$this->upload_form_field]['error'];
         if ($_FILES[$this->upload_form_field]['size'] > $this->max_file_size) {
             flash("file_too_big", '', 0, implode(",", $this->allowed_file_ext));
         }
         $isuploaded = $upload->upload($this->rename_file);
         if (!$isuploaded) {
             flash("file_too_big", '', 0, implode(",", $this->allowed_file_ext));
         }
         //insert into db.
         //$_this = & Attachments::getInstance();
         $_this = Attachments::getInstance();
         $this->file_full_url = $this->upload_url . $upload->file_copy;
         $this->file_size = $_FILES[$this->upload_form_field]['size'];
         $this->out_file_name = $upload->file_copy;
         $this->out_file_full_path = $this->out_file_path . $this->out_file_name;
         if ($this->is_image) {
             list($width, $height) = @getimagesize($this->out_file_full_path);
             $this->width = intval($width);
             $this->height = intval($height);
             if ($this->if_orignal) {
                 copy($this->out_file_full_path, $this->out_file_path . $this->rename_file . $this->orignal_file_ext . $upload->file_extension);
             }
             if ($this->if_thumb) {
                 require LIB_PATH . "thumb.class.php";
                 if ($this->if_orignal) {
                     $img = new Image($this->out_file_path . $this->rename_file . $this->orignal_file_ext . $upload->file_extension, $this->out_file_full_path);
                 } else {
                     $img = new Image($this->out_file_path . $this->rename_file . $upload->file_extension, $this->out_file_full_path);
                 }
                 if ($this->if_thumb_middle) {
                     list($width, $height) = $this->getScale("middle");
                     $img->Thumb($width, $height, '.middle.jpg');
                 }
                 list($width, $height) = $this->getScale("small");
                 $img->Thumb($width, $height);
             }
             if ($this->if_watermark) {
                 $markimg = new ImageWatermark($file_name = $this->out_file_path . $this->rename_file . $upload->file_extension);
                 $markimg->fontFile = DATA_PATH . "fonts/" . $this->fontFace;
                 if ($this->is_water_image) {
                     $markimg->appendImageMark(PHPB2B_ROOT . STATICURL . 'images/watermark.png');
                 } else {
                     $waterText = !empty($this->is_water_text) ? $this->is_water_text : pb_getenv('HTTP_HOST');
                     $markimg->color = !empty($this->water_text_color) ? $this->water_text_color : '#FF0000';
                     $markimg->angle = 0;
                     //rotate for textwatermark.
                     $markimg->appendTextMark($waterText);
                 }
                 if ($this->width > 150 || $this->height > 150) {
                     $markimg->write($file_name);
                 }
             }
             if ($this->if_thumb_large) {
                 list($width, $height) = $this->getScale("large");
                 $img->Thumb($width, $height, null);
             }
         }
         //save
         if ($this->insert_new) {
             $attach_info['attachment'] = $this->file_full_url;
             $attach_info['created'] = $attach_info['modified'] = $_this->timestamp;
             $attach_info['title'] = empty($this->title) ? reset(explode(".", $upload->the_file)) : $this->title;
             $attach_info['description'] = $this->description;
             $attach_info['file_name'] = $upload->the_file;
             $attach_info['file_name'] = $this->is_image;
             $attach_info['file_size'] = $_FILES[$this->upload_form_field]['size'];
             $attach_info['file_type'] = $_FILES[$this->upload_form_field]['type'];
             $attach_info['attachmenttype_id'] = $type_id;
//.........这里部分代码省略.........
开发者ID:reboxhost,项目名称:phpb2b,代码行数:101,代码来源:attachment_controller.php

示例2: upload_process

 function upload_process($type_id = '0')
 {
     $attach_info = array();
     if (isset($_FILES) && $_FILES[$this->upload_form_field]['size'] > 0) {
         $mimetype = new mimetype();
         if (in_array($file_ext = fileext($_FILES[$this->upload_form_field]['name']), $this->imgext)) {
             $this->is_image = 1;
             $this->allowed_file_ext = $this->imgext;
             if (!in_array($_FILES[$this->upload_form_field]['type'], $mimetype->image_mimes)) {
                 flash("format_not_support", '', 0);
             }
         }
         require LIB_PATH . "upload.class.php";
         $upload = new FileUploads();
         $upload->upload_dir = $this->out_file_path;
         $upload->extensions = $this->allowed_file_ext;
         $upload->max_file_size = $this->max_file_size;
         $upload->the_temp_file = $_FILES[$this->upload_form_field]['tmp_name'];
         $upload->the_file = $_FILES[$this->upload_form_field]['name'];
         $upload->http_error = $_FILES[$this->upload_form_field]['error'];
         if ($_FILES[$this->upload_form_field]['size'] > $this->max_file_size) {
             flash("file_too_big", '', 0, implode(",", $this->allowed_file_ext));
         }
         $isuploaded = $upload->upload($this->rename_file);
         if (!$isuploaded) {
             flash("file_too_big", '', 0, implode(",", $this->allowed_file_ext));
         }
         //insert into db.
         $_this =& Attachments::getInstance();
         $this->file_full_url = $this->upload_url . $upload->file_copy;
         $this->file_size = $_FILES[$this->upload_form_field]['size'];
         $this->out_file_name = $upload->file_copy;
         $this->out_file_full_path = $this->out_file_path . $this->out_file_name;
         $this->file_name = $upload->the_file;
         if ($this->is_image) {
             list($width, $height) = @getimagesize($this->out_file_full_path);
             $this->width = intval($width);
             $this->height = intval($height);
             if ($this->if_orignal) {
                 copy($this->out_file_full_path, $this->out_file_path . $this->rename_file . $this->orignal_file_ext . $upload->file_extension);
             }
             if ($this->if_thumb) {
                 require LIB_PATH . "thumb.class.php";
                 if ($this->if_orignal) {
                     $img = new Image($this->out_file_path . $this->rename_file . $this->orignal_file_ext . $upload->file_extension, $this->out_file_full_path);
                 } else {
                     $img = new Image($this->out_file_path . $this->rename_file . $upload->file_extension, $this->out_file_full_path);
                 }
                 if ($this->if_thumb_middle) {
                     list($width, $height) = $this->getScale("middle");
                     $img->Thumb($width, $height, '.middle.jpg');
                 }
                 list($width, $height) = $this->getScale("small");
                 $img->Thumb($width, $height);
             }
             if ($this->if_watermark) {
                 $markimg = new ImageWatermark($file_name = $this->out_file_path . $this->rename_file . $upload->file_extension);
                 $markimg->fontFile = APP_ROOT . "data/fonts/" . $this->fontFace;
                 if ($this->is_water_image) {
                     $markimg->appendImageMark(APP_ROOT . 'images/watermark.png');
                 } else {
                     $waterText = !empty($this->is_water_text) ? $this->is_water_text : URL;
                     $markimg->color = !empty($this->water_text_color) ? $this->water_text_color : '#FF0000';
                     $markimg->angle = 45;
                     $markimg->appendTextMark($waterText);
                 }
                 if ($this->width > 150 || $this->height > 150) {
                     $markimg->write($file_name);
                 }
             }
             if ($this->if_thumb_large) {
                 list($width, $height) = $this->getScale("large");
                 $img->Thumb($width, $height, null);
             }
         }
         //save
         if ($this->insert_new) {
             $attach_info['attachment'] = $this->file_full_url;
             $attach_info['created'] = $attach_info['modified'] = $_this->timestamp;
             $attach_info['title'] = empty($this->title) ? reset(explode(".", $upload->the_file)) : $this->title;
             $attach_info['description'] = $this->description;
             $attach_info['file_name'] = $upload->the_file;
             $attach_info['is_image'] = $this->is_image;
             $attach_info['file_size'] = $_FILES[$this->upload_form_field]['size'];
             $attach_info['file_type'] = $_FILES[$this->upload_form_field]['type'];
             $attach_info['attachmenttype_id'] = $type_id;
             if (isset($_SESSION['MemberID'])) {
                 $attach_info['member_id'] = intval($_SESSION['MemberID']);
             }
             $this->id = $_this->Add($attach_info);
         }
     }
 }
开发者ID:vuong93st,项目名称:w-game,代码行数:93,代码来源:attachment_controller.php


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