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. ubuntu开机自启动脚本编写

    1.将启动脚本复制到/etc/init.d目录下面 2.chmod 755 /etc/init.d/xxx 3.sudo update-rc.d /etc/init.d/xxx defaults 95 ...

  2. 一个考察for循环题 讨论一下

    一道Java程序题,主要是考察for循环如下所示: public class Test { static boolean fun(char c) { System.out.print(c); retu ...

  3. 现代程序设计——homework-09

    Lambda表达式 // homework-09.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream ...

  4. homework-06&homework-09

    homework-06 1) 把程序编译通过, 跑起来 , 把正确的 playPrev(GoMove) 的方法给实现了. public void playPrev(GoMove gm) { // ne ...

  5. Linux下文件的压缩与打包

    一.Linux下常见的文件压缩命令: 在Linux的环境中,压缩文件的扩展名大多是:『*.tar, *.tar.gz, *.tgz, *.gz, *.Z, *.bz2』,为什么会有这样的扩展名呢? 这 ...

  6. PD16 Generate Datebase For Sql2008R2时报脚本错误“对象名sysproperties无效”

    PowerDesinger16创建数据库表到SQL2008R2时,执行报"对象名sysproperties无效"错误. 主要是在建模时我们对表.列增加了些说明注释,而Sql2005 ...

  7. Qt 自动搜索串口号列表

    @功能: SerialPortList 类实现当前可用的串口进行实时扫描,当发现有新的串口 或是现有串口消失时,SerialPortList类将发出一个QStringList类型的 信号onNewSe ...

  8. Codeforces Round #353 (Div. 2) C. Money Transfers (思维题)

    题目链接:http://codeforces.com/contest/675/problem/C 给你n个bank,1~n形成一个环,每个bank有一个值,但是保证所有值的和为0.有一个操作是每个相邻 ...

  9. HDU1856More is better(并查集)

    最近发现以前的东西都忘得差不多了,在这里刷刷水题 并查集: int find_parent(int x) { return x = p[x] ? x : p[x] = find_parent(p[x] ...

  10. POJ1061青蛙的约会(扩展欧几里得)

    #include <cstdio> #include <cstring> #include <algorithm> #include <math.h> ...