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


PHP FileUtil::isBinary方法代码示例

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


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

示例1: create

 /**
  * Creates a new attachments.
  *
  * @param	string		$file
  * @param	array		$attachmentData
  * @return	AttachmentEditor
  */
 public static function create($file, $attachmentData)
 {
     $attachmentData['isBinary'] = 1;
     if (!$attachmentData['isImage']) {
         $attachmentData['isBinary'] = (int) FileUtil::isBinary($file);
     }
     // insert attachment
     $attachmentID = self::insert($attachmentData);
     $attachmentData['attachmentID'] = $attachmentID;
     $attachment = new AttachmentEditor(null, $attachmentData);
     // copy tmp file to /attachments folders
     try {
         $path = WCF_DIR . 'attachments/attachment-' . $attachmentID;
         if (!@move_uploaded_file($file, $path)) {
             throw new SystemException();
         }
         @chmod($path, 0777);
     } catch (SystemException $e) {
         // could not copy uploaded file, rollback insert statement
         $attachment->delete();
         return null;
     }
     return $attachment;
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:31,代码来源:AttachmentEditor.class.php

示例2: setAttachment

 /**
  * Saves an attachment in database and in the folder /attachments.
  * Creates a thumbnail, if necessary.
  * 
  * @param	array		$attachment
  * @return	boolean		false, if storage fails 
  */
 public function setAttachment(&$attachment)
 {
     $attachment['isBinary'] = 1;
     if (!$attachment['isImage']) {
         $attachment['isBinary'] = (int) FileUtil::isBinary($attachment['attachment']);
     }
     // insert attachment
     $attachmentID = self::insert($attachment['attachmentName'], array('packageID' => $this->packageID, 'containerID' => $attachment['messageID'], 'containerType' => $this->messageType, 'userID' => $attachment['userID'], 'attachmentSize' => $attachment['attachmentSize'], 'isImage' => $attachment['isImage'], 'sha1Hash' => $attachment['sha1Hash'], 'idHash' => $attachment['idHash'], 'uploadTime' => $attachment['uploadTime'], 'fileType' => $attachment['fileType'], 'isBinary' => $attachment['isBinary'], 'showOrder' => $attachment['showOrder']));
     $attachment['attachmentID'] = $attachmentID;
     // copy tmp file to /attachments folders
     try {
         $path = WCF_DIR . 'attachments/attachment-' . $attachmentID;
         if (!@move_uploaded_file($attachment['attachment'], $path)) {
             throw new SystemException();
         } else {
             // change attachment file path
             $attachment['attachment'] = $path;
             @chmod($path, 0777);
         }
     } catch (SystemException $e) {
         // could not copy uploaded file, rollback insert statement
         $this->delete($attachmentID);
         return false;
     }
     // create thumbnail
     if (ATTACHMENT_ENABLE_THUMBNAILS && $attachment['isImage']) {
         $this->saveThumbnail($attachment, $this->thumbnailWidth, $this->thumbnailHeight, $this->addSourceInfo, $this->useEmbedded);
     }
     return true;
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:37,代码来源:AttachmentsEditor.class.php


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