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") ...
随机推荐
- 【九度OJ】题目1096-二分查找
题目1069:查找学生信息 这篇文章中提到的问题主要是由于调试平台Visual Studio和测试平台Online Judge的一些小差异,造成在Visual Studio中调试通过的代码,在输入OJ ...
- [.NET源码学习]实例化Font,遭遇字体不存在的情况。
实例化Font类时,当传入参数为不存在或未安装的字体时,Windows系统会用Microsoft Sans Serif字体替代该字体. Msdn: "For more information ...
- 高性能、高容错、基于内存的开源分布式存储系统Tachyon的简单介绍
Tachyon是什么? Tachyon是一个高性能.高容错.基于内存的开源分布式存储系统,并具有类Java的文件API.插件式的底层文件系统.兼容Hadoop MapReduce和Apache Spa ...
- adb常用命令介绍
adb connect 命令格式:adb connect <host>[:<port>] 作用:connect to a device via TCP/IP,Port 5555 ...
- [Java基础]Java通配符
转自:http://peiquan.blog.51cto.com/7518552/1303768 本以为这会是一篇比较基础的博客,可一旦深究的时候,才发现很多有意思的东西,也发现了很多令人迷惑的地方. ...
- 对unsigned int和int进行移位操作的区别
1. 无符号整数 unsigned int 对unsigned int进行移位操作时,最高位不会有任何特殊性. 无符号整数必须使用%u来打印 #include <stdio.h> int ...
- Django settings — Django 1.6 documentation
Django settings - Django 1.6 documentation export DJANGO_SETTINGS_MODULE=mysite.settings django-admi ...
- Spark Streaming 原理剖析
通过源码呈现 Spark Streaming 的底层机制. 1. 初始化与接收数据 Spark Streaming 通过分布在各个节点上的接收器,缓存接收到的流数据,并将流数 据 包 装 成 Spar ...
- Xcode 的正确打开方式——Debugging
程序员日常开发中有大量时间都会花费在 debug 上,从事 iOS 开发不可避免地需要使用 Xcode.这篇博客就主要介绍了 Xcode 中几种能够大幅提升代码调试效率的方式. “If debuggi ...
- JSF 2 outputText example
In JSF 2.0 web application, "h:outputText" tag is the most common used tag to display plai ...