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") ...
随机推荐
- 【原】Storm实战
3.Storm实战 如何新建一个Storm 项目 本文简要概括如何新建一个Storm项目,步骤如下: 1.添加Storm 相关jar添加到类路径上. 2.如果使用多语言特性,将多语言实现的目录加到cl ...
- 你今天Python了吗?(上)
你今天Python了吗?为了提高你的生产效率,赶快去关注一下小蟒蛇的成长吧!别再把Python当作你的业余爱好了,她能为你做手头上几乎所有的工作,而且能做得更好,也让你把写代码看成是一种真正的乐趣.为 ...
- 如何在 Windows Azure 的虚拟机 ubuntu 上面安装和配置 openVPN(三)
第三步:安装openVPN 请打开 ubuntu 官方文档.然后,从上到下,按照步骤,输入执行命令.大家只需要执行到 First trouble shooting 之前即可. 不要怕麻烦,仔细读,一步 ...
- bzoj 4448 [Scoi2015]情报传递(主席树,LCA)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=4448 [题意] 给定一颗树,询问一条路径上权值小于t-c的点数. [思路] 将一个2查 ...
- 读《HTML5与CSS3权威指南(上册)》笔记
第二章 1.内容类型:“text/html”.DOCTYPE声明:<!DOCTYPE html>.指定字符编码:<meta charset="utf-8"> ...
- Hive1.3 JDBC连接-代码片段
package com.hive.jdbc; import java.sql.Connection; import java.sql.DriverManager; import java.sql.Re ...
- vbox磁盘空间扩容
前提:将虚拟机真正关机,不能在仅状态保存的场合做磁盘扩容. 步骤1.获取需要增加容量的映像的uuid 在vbox的安装目录下使用命令行:VBoxManage list hdds 得到结果如下: UUI ...
- Spark RDD概念学习系列之细谈RDD的弹性(十六)
细谈RDD的弹性 所谓,弹性,是指在内存不够时可以与磁盘进行交换. 弹性之一:自动的进行内存和磁盘数据存储的切换 弹性之二:基于Lineage(血缘)的高效容错 弹性之三:Task如果失败会 ...
- 【转】并发编程之Operation Queue
http://blog.xcodev.com/blog/2013/10/28/operation-queue-intro/ 随着移动设备的更新换代,移动设备的性能也不断提高,现在流行的CPU已经进入双 ...
- ocp 1Z0-047 61-130题解析
61. Evaluate the following SQL statements that are issued in the given order:CREATE TABLE emp(emp_no ...