文件处理核心类
API - Core_File
- File::$dir - 允许读写操作的目录
- File::is_file - 文件是否存在
- File::create_file - 创建一个文件,多服务器可以自动同步
- File::create_dir - 循环建立目录,多服务器可以自动同步
- File::unlink - 删除文件,支持多个文件,多服务器可以自动同步
- File::remove_dir - 循环删除目录下的所有目录和文件,多服务器可以自动同步
- File::move_dir - 转移目录下的所有目录和文件,多服务器可以自动同步,可操作非空目录
- File::copy_dir - 复制目录下的所有目录和文件到另外一个目录
- File::sync - 将指定的文件同步到其它服务器
- File::split - Split a file into pieces matching a specific size. Used when you need to
- File::join - Join a split file into a whole file. Does the reverse of [File::split].
- File::mime - 返回指定文件类型
- File::mime_by_ext - Return the mime type of an extension.
- File::mimes_by_ext - Lookup MIME types for a file
- File::exts_by_mime - Lookup file extensions by MIME type
- File::ext_by_mime - Lookup a single file extension by MIME type.
- File::__construct - 初始化文件对象
文件是否存在
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$file |
string |
$file | |
$storage |
unknown |
string(7) "default" |
创建一个文件,多服务器可以自动同步
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$file |
string |
$file | |
$data |
$data |
||
$flags |
$flags |
null | |
$context |
$context |
null | |
$storage |
string |
物理存储组,不传则为默认 | string(7) "default" |
boolean
循环建立目录,多服务器可以自动同步
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$dir |
string |
待创建的文件夹 | |
$auto_create_default_file |
boolean |
新创建的文件夹,是否自动创建空默认页 | bool true |
$storage |
string |
物理存储组,不传则为默认 | string(7) "default" |
boolean
true/false删除文件,支持多个文件,多服务器可以自动同步
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$file |
string/array |
$file | |
$storage |
string |
物理存储组,不传则为默认 | string(7) "default" |
boolean
循环删除目录下的所有目录和文件,多服务器可以自动同步
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$dir |
string |
Name | |
$storage |
string |
物理存储组,不传则为默认 | string(7) "default" |
boolean
转移目录下的所有目录和文件,多服务器可以自动同步,可操作非空目录
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$fromdir |
string |
源文文件目录 | |
$todir |
string |
目标文件目录 | |
$autocoverageold |
boolean |
是否覆盖已有文件,true覆盖,false跳过 | bool true |
$storage |
string |
物理存储组,不传则为默认 | string(7) "default" |
array($dook,$doerror)
复制目录下的所有目录和文件到另外一个目录
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$fromdir |
string |
源文文件目录 | |
$todir |
string |
目标文件目录 | |
$autocoverageold |
boolean |
是否覆盖已有文件,true覆盖,false跳过 | bool true |
$storage |
string |
物理存储组,不传则为默认 | string(7) "default" |
array($dook,$doerror)
将指定的文件同步到其它服务器
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$file |
string |
Name | |
$storage |
unknown |
string(7) "default" |
boolean
Split a file into pieces matching a specific size. Used when you need to split large files into smaller pieces for easy transmission.
$count = File::split($file);
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$filename |
string |
File to be split | |
$piece_size |
string |
Directory to output to, defaults to the same directory as the file | integer 10 |
$storage |
integer |
Size, in MB, for each piece to be | string(7) "default" |
integer
The number of pieces that were createdJoin a split file into a whole file. Does the reverse of [File::split].
$count = File::join($file);
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$filename |
string |
Split filename, without .000 extension | |
$storage |
string |
Output filename, if different then an the filename | string(7) "default" |
integer
The number of pieces that were joined.返回指定文件类型
$mime = File::mime($file);
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$filename |
string |
File name or path |
string
mime type on successFALSE
on failureReturn the mime type of an extension.
$mime = File::mime_by_ext('png'); // "image/png"
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$extension |
string |
Extension: php, pdf, txt, etc |
string
mime type on successFALSE
on failureLookup MIME types for a file
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$extension |
string |
Extension to lookup |
array
Array of MIMEs associated with the specified extensionLookup file extensions by MIME type
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$type |
string |
File MIME type |
array
File extensions matching MIME typeLookup a single file extension by MIME type.
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$type |
string |
MIME type to lookup |
mixed
First file extension matching or false调用HttpServer执行
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$storage |
string |
$storage | |
$uri |
string |
$uri | |
$arg1 |
mixed |
$arg1 | null |
$arg2 |
mixed |
$arg2 | null |
boolean
mixed获取同步模式
string
是否可以直接执行
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$storage |
string |
$storage |
boolean
检查并且获取系统允许读写路径信息,如果不合法则返回false
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$file |
string/array |
$file |
array($key,$path)