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. matlab的&和&&操作

    A&B(1)首先判断A的逻辑值,然后判断B的值,然后进行逻辑与的计算.(2)A和B可以为矩阵(e.g. A=[1 0],B=[0 0]).A&&B(1)首先判断A的逻辑值,如果 ...

  2. SVM原理简介

    本文只是简单介绍一下SVM的理论框架,想要详细了解当中细节问题处理可以参看后续章节或者网上各种详细资料.推荐Andrew Ng的斯坦福大学机器学习课程. 年代中期发展起来的基于统计学习理论的一种机器学 ...

  3. Tkinter教程之Button篇(1)

    本文转载自:http://blog.csdn.net/jcodeer/article/details/1811298 #Tkinter教程之Button篇(1)#Button功能触发事件'''1.一个 ...

  4. lipo命令

    工作中,xcode工程遇到一个bug file was built for archive which is not the architecture being linked armv7 找了一些资 ...

  5. ColorNote.疑难解答

    首先感谢你对colornote的支持 在使用此应用的过程中,存在任何问题,请先在此页面查看是否有对应的解决方案[Ctrl + F 搜索] 如果问题无法解决,请在页面下方留言,或者邮件light.z@q ...

  6. JDBC学习笔记(9)——DBUtils的使用

    使用DBUtils提供的功能需要使用commons-dbutils-1.6.jar这个JAR包,在Apache官网可以下载到 使用DBUtils进行更新操 测试QueryRunner类的update方 ...

  7. DataSnap与FireDAC三层

    相交资料: http://blog.csdn.net/shuaihj/article/details/6129131http://www.cnblogs.com/hnxxcxg/p/4007876.h ...

  8. F5 刷新功能

    //1.引入单元 uses ShlObj; //2.执行命令 procedure TForm1.Button1Click(Sender: TObject); begin SHChangeNotify( ...

  9. WEB开发框架

  10. [iOS 多线程 & 网络 - 2.10] - ASI框架下载文件

    A.ASI框架中的下载 1.实现步骤 在实际的开发中如果要使用asi框架来下载服务器上的文件,只需要执行下面简单的几个步骤即可. (1)创建请求对象:(2)设置下载文件保存的路径:(3)发送下载文件的 ...