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


PHP AttachmentFile::create方法代碼示例

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


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

示例1: run

 function run($runtime)
 {
     $errors = array();
     $i18n = new Internationalization('en_US');
     $tpls = $i18n->getTemplate('email_template_group.yaml')->getData();
     foreach ($tpls as $t) {
         // If the email template group specifies an id attribute, remove
         // it for upgrade because we cannot assume that the id slot is
         // available
         unset($t['id']);
         EmailTemplateGroup::create($t, $errors);
     }
     $files = $i18n->getTemplate('file.yaml')->getData();
     foreach ($files as $f) {
         $id = AttachmentFile::create($f, $errors);
         // Ensure the new files are never deleted (attached to Disk)
         $sql = 'INSERT INTO ' . ATTACHMENT_TABLE . ' SET object_id=0, `type`=\'D\', inline=1' . ', file_id=' . db_input($id);
         db_query($sql);
     }
 }
開發者ID:dmiguel92,項目名稱:osTicket-1.8,代碼行數:20,代碼來源:d51f303a-dad45ca2.task.php

示例2: savefile

 public function savefile($uid, $original_file_path, $original_basename, $file_name = NULL, $file_ext = NULL, $description = NULL)
 {
     if (!file_exists($original_file_path)) {
         return FALSE;
     }
     is_null($file_ext) && ($file_ext = strtolower(pathinfo($original_basename, PATHINFO_EXTENSION)));
     is_null($file_name) && ($file_name = mb_basename($original_basename, '.' . $file_ext));
     //支持中文的basename
     $size = filesize($original_file_path);
     if (!in_array($file_ext, $this->_config['ext'])) {
         return static::UPLOAD_ERR_EXT;
     }
     if ($size > $this->_config['maxsize']) {
         return static::UPLOAD_ERR_MAXSIZE;
     }
     if (empty($size)) {
         return static::UPLOAD_ERR_EMPTY;
     }
     //傳文件都耗費了那麽多時間,還怕md5?
     $hash = md5_file($original_file_path);
     $file = $this->fileModel->get_byhash($hash, $size);
     if (empty($file)) {
         $new_basename = $this->_get_hash_basename();
         $new_hash_path = $this->get_hash_path($new_basename);
         if (!$this->_save_file($original_file_path, $new_basename)) {
             return static::UPLOAD_ERR_SAVE;
         }
         $file = AttachmentFile::create(['basename' => $new_basename, 'path' => $new_hash_path, 'hash' => $hash, 'size' => $size]);
     } else {
         //已經存在此文件
         @unlink($original_file_path);
     }
     $attachment = $this->create(['afid' => $file->getKey(), 'filename' => $file_name, 'ext' => $file_ext, 'original_basename' => $original_basename, 'description' => $description, 'uid' => $uid]);
     //當前Model更新
     //$this->setRawAttributes($attachment->getAttributes(), true);
     return $this->get($attachment->getKey());
 }
開發者ID:unionbt,項目名稱:hanpaimall,代碼行數:37,代碼來源:Attachment.php


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