File
in package
File class for work with files and folders
Table of Contents
- $BYTE_TO_GIB : string
- Byte to Gigabyte
- $BYTE_TO_KIB : string
- Byte to Kilobyte
- $BYTE_TO_MIB : string
- Byte to Megabyte
- $GIB_TO_BYTE : string
- Gigabyte to byte
- $GIB_TO_KIB : string
- Gigabyte to Kilobyte
- $GIB_TO_MIB : string
- Gigabyte to Megabyte
- $KIB_TO_BYTE : string
- Kilobyte to byte
- $KIB_TO_GIB : string
- Kilobyte to Gigabyte
- $KIB_TO_MIB : string
- Kilobyte to Megabyte
- $MIB_TO_BYTE : string
- Megabyte to byte
- $MIB_TO_GIB : string
- Megabyte to Gigabyte
- $MIB_TO_KIB : string
- Megabyte to Kilobyte
- $file_path : string
- File path
- __construct() : mixed
- Create a object
- append() : bool
- Append data to a file
- arrayToJsonFile() : bool
- Conver array to a json file
- changeFile() : void
- Change file path
- currentFile() : string
- Return current file path
- delete() : bool
- delete a file
- jsonFileToArray() : mixed
- Read json file and convert to array
- makeDir() : bool
- Make direction folder and path
- read() : void
- Reading a file
- sizeConverter() : float
- convert file size
- upload() : void
- upload your files
- write() : bool
- Write a file with your data
Properties
$BYTE_TO_GIB
Byte to Gigabyte
public
string
$BYTE_TO_GIB
= -3
BYTE_TO_GIB
$BYTE_TO_KIB
Byte to Kilobyte
public
string
$BYTE_TO_KIB
= -1
BYTE_TO_KIB
$BYTE_TO_MIB
Byte to Megabyte
public
string
$BYTE_TO_MIB
= -2
BYTE_TO_MIB
$GIB_TO_BYTE
Gigabyte to byte
public
string
$GIB_TO_BYTE
= 3
GIB_TO_BYTE
$GIB_TO_KIB
Gigabyte to Kilobyte
public
string
$GIB_TO_KIB
= 2
GIB_TO_KIB
$GIB_TO_MIB
Gigabyte to Megabyte
public
string
$GIB_TO_MIB
= 1
GIB_TO_MIB
$KIB_TO_BYTE
Kilobyte to byte
public
string
$KIB_TO_BYTE
= 1
KIB_TO_BYTE
$KIB_TO_GIB
Kilobyte to Gigabyte
public
string
$KIB_TO_GIB
= -2
KIB_TO_GIB
$KIB_TO_MIB
Kilobyte to Megabyte
public
string
$KIB_TO_MIB
= -1
KIB_TO_MIB
$MIB_TO_BYTE
Megabyte to byte
public
string
$MIB_TO_BYTE
= 2
MIB_TO_BYTE
$MIB_TO_GIB
Megabyte to Gigabyte
public
string
$MIB_TO_GIB
= -1
MIB_TO_GIB
$MIB_TO_KIB
Megabyte to Kilobyte
public
string
$MIB_TO_KIB
= 1
MIB_TO_KIB
$file_path
File path
protected
string
$file_path
Methods
__construct()
Create a object
public
__construct([mixed $file_path = null ]) : mixed
Parameters
- $file_path : mixed = null
Return values
mixed —append()
Append data to a file
public
append([string $text = "" ][, string|null $file_path = null ]) : bool
Parameters
- $text : string = ""
-
data to append end of file
- $file_path : string|null = null
Tags
Return values
bool —arrayToJsonFile()
Conver array to a json file
public
static arrayToJsonFile(array<string|int, mixed> $json, string $file_name[, bool $overwrite = false ]) : bool
Parameters
- $json : array<string|int, mixed>
-
Array data
- $file_name : string
-
File name for saving .JSON
- $overwrite : bool = false
-
If this file exist overwrite?
Tags
Return values
bool —changeFile()
Change file path
public
changeFile(string $new_file) : void
Parameters
- $new_file : string
-
New file path
Tags
Return values
void —currentFile()
Return current file path
public
currentFile() : string
Tags
Return values
string —delete()
delete a file
public
delete([string|null $file_path = null ]) : bool
Parameters
- $file_path : string|null = null
-
path of file to delete
Tags
Return values
bool —jsonFileToArray()
Read json file and convert to array
public
static jsonFileToArray(string $file_name) : mixed
Parameters
- $file_name : string
-
Name of json file
Tags
Return values
mixed —false|Array
makeDir()
Make direction folder and path
public
makeDir([string|null $target_dir = null ]) : bool
Parameters
- $target_dir : string|null = null
-
Path to make
Tags
Return values
bool —read()
Reading a file
public
read([string $file_path = null ]) : void
Parameters
- $file_path : string = null
-
File path
Tags
Return values
void —sizeConverter()
convert file size
public
static sizeConverter(float $number, int $type[, int $precision = 2 ][, int $mode = PHP_ROUND_HALF_UP ]) : float
Parameters
- $number : float
-
Input number
- $type : int
-
BYTE_TO_KIB | BYTE_TO_GIB | BYTE_TO_MIB | KIB_TO_BYTE | KIB_TO_MIB | KIB_TO_GIB | MIB_TO_BYTE | MIB_TO_KIB | MIB_TO_GIB | GIB_TO_BYTE | GIB_TO_KIB | GIB_TO_MIB
- $precision : int = 2
- $mode : int = PHP_ROUND_HALF_UP
Return values
float —upload()
upload your files
public
upload(string $form_name, string $target_dir, int $max_upload_size, int $size_limit[, bool $is_null = true ][, array<string|int, mixed> $type = ["*"] ][, array<string|int, mixed> $target_name = [] ][, string $write_method = "o" ][, bool $log = true ]) : void
Parameters
- $form_name : string
-
Name of form in HTML set
- $target_dir : string
-
Target path for uploading
- $max_upload_size : int
-
Max of all file sizes byte, default is '0' for no limitation
- $size_limit : int
-
Max every file size byte, default is '0' for no limitation
- $is_null : bool = true
-
Can upload null file ? default is 'true'
- $type : array<string|int, mixed> = ["*"]
-
Which file extention can upload ? default is ["*"] for no limitation
- $target_name : array<string|int, mixed> = []
-
Insert target name of uploaded file, default is [] for no renaming and set original name
- $write_method : string = "o"
-
If file exist, function must what to do OVERWRITE, SKIPPING, Rename. default method is 'o', all option 'o|s|r'
- $log : bool = true
-
Are want to get summery log of uploaded files, default is 'true'
Tags
Return values
void —string|boolean
write()
Write a file with your data
public
write([string $text = "" ][, string|null $file_path = null ]) : bool
Parameters
- $text : string = ""
-
data for writing
- $file_path : string|null = null