Helpers\Document
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的更多相关文章
- Config
Config Config App Auth Cache Database Languages Mail Modules Routing Session Config Settings for the ...
- [asp.net core] Tag Helpers 简介(转)
原文地址 https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/intro What are Tag Helpers? ...
- Helpers\RainCaptcha
Helpers\RainCaptcha This class can validate CAPTCHA images with RainCaptcha. It can generate an URL ...
- 简单分析下用yii2的yii\helpers\Html类和yii.js实现的post请求
yii2提供了很多帮助类,比如Html.Url.Json等,可以很方便的实现一些功能,下面简单说下这个Html.用yii2写view时时经常会用到它,今天在改写一个页面时又用到了它.它比较好用的地方就 ...
- ElasticSearch Document API
删除索引库 可以看到id为1的索引库不见了 这里要修改下配置文件 slave1,slave2也做同样的操作,在这里就不多赘述了. 这个时候记得要重启elasticseach才能生效,怎么重启这里就不多 ...
- Helpers.parallel_bulk in Python not working?
Helpers.parallel_bulk in Python not working? 学习了:https://discuss.elastic.co/t/helpers-parallel-bulk- ...
- js 函数的防抖(debounce)与节流(throttle) 带 插件完整解析版 [helpers.js]
前言: 本人纯小白一个,有很多地方理解的没有各位大牛那么透彻,如有错误,请各位大牛指出斧正!小弟感激不尽. 函数防抖与节流是做什么的?下面进行通俗的讲解. 本文借鉴:h ...
- document.documentElement.clientHeight 与 document.body.clientHeight(杜绝千篇一律的抄袭!!)
document.documentElement.clientHeight 与 document.body.clientHeight用来获取页面可视高度我觉得有点问题.这两个应该不是一个东西. 页面中 ...
- jquery中的$(document).ready(function() {});
当文档载入时执行function函数里的代码, 这部分代码主要声明,页面加载后 "监听事件" 的方法.例如: $(document).ready( $("a") ...
随机推荐
- C#插入排序详解
这几天一直在研究算法,也算有点心得,现在跟大家分享一下,我是用C#做的 排序算法是想要成为大虾程序员必须要掌握的技术,它其实也是一种思想,你对算法熟悉,对以后编程有很大帮助 算法思路 ⒈ 从第一个元素 ...
- 最长公共子序列LCS
LCS:给出两个序列S1和S2,求出的这两个序列的最大公共部分S3就是就是S1和S2的最长公共子序列了.公共部分 必须是以相同的顺序出现,但是不必要是连续的. LCS具有最优子结构,且满足重叠子问题的 ...
- Java 从单核到多核的多线程(并发)
JAVA 并发编程 最初计算机是单任务的,然后发展到多任务,接着出现多线程并行,同时计算机也从单cpu进入到多cpu.如下图: 多任务:其实就是利用操作系统时间片轮转使用的原理.操作系统通 ...
- Base64编解码(C++版)
#include <string> using namespace std; class ZBase64 { public: /*编码 DataByte [ ...
- ThinkPHP框架的网站url重写
nginx location / { root /var/www; index index.html index.htm index.php; if (!-e $request_filename) { ...
- POJ 2763 Housewife Wind (树链剖分 有修改单边权)
题目链接:http://poj.org/problem?id=2763 n个节点的树上知道了每条边权,然后有两种操作:0操作是输出 当前节点到 x节点的最短距离,并移动到 x 节点位置:1操作是第i条 ...
- C#枚举数值与名称的转换
在应用枚举的时候,时常需要将枚举和数值相互转换的情况.有时候还需要转换成相应的中文.下面介绍一种方法. 首先建立一个枚举: /// <summary> /// 颜色 /// </su ...
- POJ 3671 Dining Cows (DP,LIS, 暴力)
题意:给定 n 个数,让你修改最少的数,使得这是一个不下降序列. 析:和3670一思路,就是一个LIS,也可以直接暴力,因为只有两个数,所以可以枚举在哪分界,左边是1,右边是2,更新答案. 代码如下: ...
- 12个有趣的C语言面试题
摘要:12个C语言面试题,涉及指针.进程.运算.结构体.函数.内存,看看你能做出几个! 1.gets()函数 问:请找出下面代码里的问题: #include<stdio.h> int ma ...
- SQL Server中使用convert进行日期转换
使用 CONVERT: CONVERT (data_type[(length)],expression[,style]) 参数 expression 是任何有效的 Microsoft® SQL Ser ...