Helpers\Document

The document class is a collection of useful methods for working with files.

To get the extension of a file call the getExtension method and pass the file name, the extension will then be returned.

Create an alias

use Helpers\Document;
Document::getExtension('customfile.zip'); //returns zip

To remove the extension of a file call the removeExtension method and pass the file name, the extension will then be removed and returned.

Document::removeExtension('customfile.zip'); //returns customfile

To find out the size in a human readable way call the formatBytes method:

Document::formatBytes('4562'); //returns 4.46 KB

Using the getFileType a filename is passed and returned is the name of the group that extension belongs to if no matches that 'Other' is returned.

These are the current groups:

  • \$images = array('jpg', 'gif', 'png', 'bmp');
  • \$docs = array('txt', 'rtf', 'doc', 'docx', 'pdf');
  • \$apps = array('zip', 'rar', 'exe', 'html');
  • \$video = array('mpg', 'wmv', 'avi', 'mp4');
  • \$audio = array('wav', 'mp3');
  • \$db = array('sql', 'csv', 'xls','xlsx');
Document::getFileType('customfile.zip'); //returns Application

Helpers\Document的更多相关文章

  1. Config

    Config Config App Auth Cache Database Languages Mail Modules Routing Session Config Settings for the ...

  2. [asp.net core] Tag Helpers 简介(转)

    原文地址 https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/intro What are Tag Helpers? ...

  3. Helpers\RainCaptcha

    Helpers\RainCaptcha This class can validate CAPTCHA images with RainCaptcha. It can generate an URL ...

  4. 简单分析下用yii2的yii\helpers\Html类和yii.js实现的post请求

    yii2提供了很多帮助类,比如Html.Url.Json等,可以很方便的实现一些功能,下面简单说下这个Html.用yii2写view时时经常会用到它,今天在改写一个页面时又用到了它.它比较好用的地方就 ...

  5. ElasticSearch Document API

    删除索引库 可以看到id为1的索引库不见了 这里要修改下配置文件 slave1,slave2也做同样的操作,在这里就不多赘述了. 这个时候记得要重启elasticseach才能生效,怎么重启这里就不多 ...

  6. Helpers.parallel_bulk in Python not working?

    Helpers.parallel_bulk in Python not working? 学习了:https://discuss.elastic.co/t/helpers-parallel-bulk- ...

  7. js 函数的防抖(debounce)与节流(throttle) 带 插件完整解析版 [helpers.js]

    前言:         本人纯小白一个,有很多地方理解的没有各位大牛那么透彻,如有错误,请各位大牛指出斧正!小弟感激不尽.         函数防抖与节流是做什么的?下面进行通俗的讲解. 本文借鉴:h ...

  8. document.documentElement.clientHeight 与 document.body.clientHeight(杜绝千篇一律的抄袭!!)

    document.documentElement.clientHeight 与 document.body.clientHeight用来获取页面可视高度我觉得有点问题.这两个应该不是一个东西. 页面中 ...

  9. jquery中的$(document).ready(function() {});

    当文档载入时执行function函数里的代码, 这部分代码主要声明,页面加载后 "监听事件" 的方法.例如: $(document).ready( $("a") ...

随机推荐

  1. C++类与对象

    [1]类的内存问题 类是抽象的,不占用内存,而对象是具体的,占用 存储空间.在一开始时弄清对象和类的关系是十分 重要的.[2]类的声明 如果在类的定义中既不指定private也不指定public,则系 ...

  2. MapReducer Counter计数器的使用,Combiner ,Partitioner,Sort,Grop的使用,

    一:Counter计数器的使用 hadoop计数器:可以让开发人员以全局的视角来审查程序的运行情况以及各项指标,及时做出错误诊断并进行相应处理. 内置计数器(MapReduce相关.文件系统相关和作业 ...

  3. C# 释放非托管资源

    C#中资源分为托管资源和非托管资源. 托管资源由垃圾回收器控制如何释放,不需要程序员过多的考虑(当然也程序员也可以自己释放). 非托管资源需要自己编写代码来释放.那么编写好的释放非托管资源的代码(释非 ...

  4. Can jxta be used to develop online card game (p2p style)?

    Can jxta be used to develop online card game (p2p style)? https://www.java.net//node/677134 I am new ...

  5. MongoDB 字段增长

    MongoDB中存储的文档必须有一个"_id"键.这个键的值可以是任何类型的,默认是个ObjectId对象. ObjectId 是一个12字节 BSON 类型数据,有以下格式: 前 ...

  6. Oracle导入导出之dmp

    Oracle导入导出有两种方式,分别是imp/exp与impdp/expdp. 1.imp/exp exp scott/tiger file=d:\test.dmp log=d:\test.log o ...

  7. JSF 2 multiple select dropdown box example

    In JSF, <h:selectManyMenu /> tag is used to render a multiple select dropdown box – HTML selec ...

  8. linux下登陆用户的行为信息—w和who命令详解

    查看用户的操作系统管理员若想知道某一时刻用户的行为,只需要输入命令w 即可,在SHELL终端中输入如下命令: [root@localhost ~]# w 可以看到执行w命令及显示结果. 命令信息含义上 ...

  9. aspose.cell制作excel常见写法

    //设置Excel的基本格式信息 Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets[]; St ...

  10. HTML5几种常见的错误写法

    本文介绍了HTML5常见的6种错误写法,包括:1.不要使用section作为div的替代品 2.只在需要的时候使用header和hgroup 3.不要把所有列表式的链接放在nav里 4.figure元 ...