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. mysql_connect v/s mysql_pconnect

    原文:mysql_connect v/s mysql_pconnect 译文:mysql_connect v/s mysql_pconnect 译者:dwqs 当需要使用PHP连接MySQL数据库的时 ...

  2. JavaScript数值转换总结

    在JavaScript中,数值转换一般有三种方式: 一.Number(param)函数:param可以用于任何数据类型 1.1  param是Boolean值,true和false分别转换为1和0: ...

  3. hive-mysql安装配置

    默认情况下,hive的元数据信息存储在内置的Derby数据中.Facebook将hive元数据存储在关系数据库 1.安装好mysql ,sudo apt-get install mysql-serve ...

  4. 【hadoop代码笔记】Mapreduce shuffle过程之Map输出过程

    一.概要描述 shuffle是MapReduce的一个核心过程,因此没有在前面的MapReduce作业提交的过程中描述,而是单独拿出来比较详细的描述. 根据官方的流程图示如下: 本篇文章中只是想尝试从 ...

  5. hibernate 连接数据库时报错

         错误信息 : com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allo ...

  6. ffmpeg 研究

    ffmpeg -codecs | grep mp3 可以查看ffmpeg是否把mp3编解码模块编译进去了. libmp3lame is the mp3 encoder for ffmpeg. It n ...

  7. Java多线程编程模式实战指南:Active Object模式(上)

    Active Object模式简介 Active Object模式是一种异步编程模式.它通过对方法的调用与方法的执行进行解耦来提高并发性.若以任务的概念来说,Active Object模式的核心则是它 ...

  8. boost::bind 和 boost::function 基本用法

    这是一篇介绍bind和function用法的文章,起因是近来读陈硕的文章,提到用bind和function替代继承,于是就熟悉了下bind和function的用法,都是一些网上都有的知识,记录一下,期 ...

  9. Android实例-获取程序版本号(XE10+小米2)

    相关资料: 383675978群号 实例源码: unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, Sy ...

  10. DATASNAP多表提交之事务控制之通用方法

    ERP系统的单据,总是些主从表结构,有一个主表,N个子表,子表又有子表,形成N层,单据数据提交时,主从表数据都要提交,为了保证数据的完整性,必须提供事务控制,要么都提交成功,有一个提交失败所有的提交都 ...