WIKINDX API 6.10.2

FILE

Table of Contents

Functions

setHeaders()  : void
Set download headers
readfile_chunked()  : bool
Download file to user
createFileName()  : array<string|int, mixed>
create a fileName for this file. If directory based on session ID does not exist, create it.
fileAttachUploadMaxSize()  : int
Get attachment max upload size in bytes
imageUploadMaxSize()  : int
Get image max upload size in bytes
fileUploadMaxSize()  : int
Get file max upload size in bytes
return_bytes()  : int
Convert some ini values to numerical values (to bytes)
dirToArray()  : array<string|int, mixed>
Enumerate files and subdirectories of a directory except . and .. subdirectories
dirInDirToArray()  : array<string|int, mixed>
Enumerate subdirectories of a directory except . and .. subdirectories
fileInDirToArray()  : array<string|int, mixed>
Enumerate files of a directory except . and .. subdirectories
recurse_AbsoluteDirToArray()  : array<string|int, mixed>
Enumerate recursively files and subdirectories of a directory except . and .. subdirectories
recurse_fileInDirToArray()  : array<string|int, mixed>
Enumerate recursively files and subdirectories of a directory except . and .. subdirectories
recurse_dir_copy()  : void
Copy recursively a folder
recurse_rmdir()  : void
Remove recursively a folder
rmfile()  : void
Remove a file
fileUpload()  : array<string|int, mixed>
Return filename, hash, type and size of an uploaded file or an array of such information for each file uploaded
rearrangeFilesArray()  : array<string|int, mixed>
Rearrange the $_FILES array for multiple file uploads
fileStore()  : bool
Store uploaded file in given directory with given name
listFiles()  : array<string|int, mixed>
list and HTML format all files for sessionID
tidyFiles()  : void
tidy up the files directory by removing all files and folders older than WIKINDX_FILE_DELETE_SECONDS
zip()  : mixed
Zip up an array of files. File is stored in files dir.
read_json_file()  : mixed
Read a JSON file to a data structure
write_json_file()  : int
Write a data structure to a JSON file
formatSize()  : string
Format a file size in bytes to the greater multiple for display
getMimeType()  : string
Return the mime-type of a file
getExtension()  : string
Return the extension of a file in lowercase (without point)
replaceFileExtension()  : string
Replace the extension of a file by an other
removeFileExtension()  : string
Remove the extension of a file path (and its point)
base64_encode_file()  : void
Encode a file with base64 as an other file
base64_decode_file()  : void
Encode a file with base64 as an other file
bin2hex_encode_file()  : void
Encode a file with bin2hex as an other file
hash_path()  : string
Generates a hash of a file or directory at the given path with the specified algo.

Functions

setHeaders()

Set download headers

setHeaders(string $type, int $size, string $filename, string $lastmodified[, string $mode = 'inline' ][, string $charset = '' ]) : void
Parameters
$type : string
$size : int
$filename : string
$lastmodified : string
$mode : string = 'inline'

'inline' or 'attachment' ('attachment' forces the download)

$charset : string = ''

Default is ''

readfile_chunked()

Download file to user

readfile_chunked(string $file) : bool

From http://uk3.php.net/function.readfile

Parameters
$file : string
Return values
bool

createFileName()

create a fileName for this file. If directory based on session ID does not exist, create it.

createFileName(string $dirName, string $string, string $extension) : array<string|int, mixed>
Parameters
$dirName : string
$string : string

File contents

$extension : string

File extension

Return values
array<string|int, mixed>

(filename, full filepath)

fileAttachUploadMaxSize()

Get attachment max upload size in bytes

fileAttachUploadMaxSize() : int

WIKINDX_FILE_ATTACH_SIZE_UPPER_LIMIT is the upper limit

Return values
int

imageUploadMaxSize()

Get image max upload size in bytes

imageUploadMaxSize() : int

WIKINDX_IMG_SIZE_UPPER_LIMIT is the upper limit

Return values
int

fileUploadMaxSize()

Get file max upload size in bytes

fileUploadMaxSize() : int

1G is the upper limit

Return values
int

return_bytes()

Convert some ini values to numerical values (to bytes)

return_bytes(int|string $val) : int
Parameters
$val : int|string
Return values
int

dirToArray()

Enumerate files and subdirectories of a directory except . and .. subdirectories

dirToArray(string $dir) : array<string|int, mixed>
Parameters
$dir : string

A directory to explore

Return values
array<string|int, mixed>

An array of file and subdirectory names

dirInDirToArray()

Enumerate subdirectories of a directory except . and .. subdirectories

dirInDirToArray(string $dir) : array<string|int, mixed>
Parameters
$dir : string

A directory to explore

Return values
array<string|int, mixed>

An array of subdirectory names

fileInDirToArray()

Enumerate files of a directory except . and .. subdirectories

fileInDirToArray(string $dir) : array<string|int, mixed>
Parameters
$dir : string

A directory to explore

Return values
array<string|int, mixed>

An array of filenames

recurse_AbsoluteDirToArray()

Enumerate recursively files and subdirectories of a directory except . and .. subdirectories

recurse_AbsoluteDirToArray(string $dir) : array<string|int, mixed>
Parameters
$dir : string

A directory to explore

Return values
array<string|int, mixed>

An array of file and subdirectory absolute paths

recurse_fileInDirToArray()

Enumerate recursively files and subdirectories of a directory except . and .. subdirectories

recurse_fileInDirToArray(string $dir) : array<string|int, mixed>
Parameters
$dir : string

A directory to explore

Return values
array<string|int, mixed>

An array of file and subdirectory paths

recurse_dir_copy()

Copy recursively a folder

recurse_dir_copy(string $src, string $dst) : void
Parameters
$src : string

Source directory

$dst : string

Destination directory

recurse_rmdir()

Remove recursively a folder

recurse_rmdir(string $dir) : void
Parameters
$dir : string

Target directory

rmfile()

Remove a file

rmfile(string $file) : void
Parameters
$file : string

Target filename

fileUpload()

Return filename, hash, type and size of an uploaded file or an array of such information for each file uploaded

fileUpload([false|string $filename = FALSE ][, bool $multiple = FALSE ]) : array<string|int, mixed>
Parameters
$filename : false|string = FALSE
$multiple : bool = FALSE

multiple files (default FALSE)

Return values
array<string|int, mixed>

(filename, hash, type, size) or array of these

rearrangeFilesArray()

Rearrange the $_FILES array for multiple file uploads

rearrangeFilesArray(array<string|int, mixed> $files) : array<string|int, mixed>
Parameters
$files : array<string|int, mixed>
Return values
array<string|int, mixed>

fileStore()

Store uploaded file in given directory with given name

fileStore(string $dirName, string $name[, int|false $index = FALSE ]) : bool
Parameters
$dirName : string
$name : string
$index : int|false = FALSE

if moving multiple file uploads

Return values
bool

listFiles()

list and HTML format all files for sessionID

listFiles() : array<string|int, mixed>
Return values
array<string|int, mixed>

(filesDir, fileDeleteSecs, fileArray)

tidyFiles()

tidy up the files directory by removing all files and folders older than WIKINDX_FILE_DELETE_SECONDS

tidyFiles() : void

zip()

Zip up an array of files. File is stored in files dir.

zip(array<string|int, mixed> $files, string $dirpath) : mixed
Parameters
$files : array<string|int, mixed>

unqualified filenames (key is label of file, value is filename on disk)

$dirpath : string

directory path

Return values
mixed

unqualified SHA1'ed filename of zip or FALSE if failure

read_json_file()

Read a JSON file to a data structure

read_json_file(string $file) : mixed

Read a JSON file and unserialize its content to a data structure with json_decode()

Parameters
$file : string

An absolute or relative path to a file

Tags
see
https://www.php.net/manual/en/function.json-decode.php
Return values
mixed

A value, a data structure, or NULL on error

write_json_file()

Write a data structure to a JSON file

write_json_file(string $file, mixed $data) : int

Serialize a data structure with json_encode() and write it in a file

Parameters
$file : string

An absolute or relative path to a file

$data : mixed

A data structure or a value

Tags
see
https://www.php.net/manual/en/function.json-encode.php
Return values
int

JSON_ERROR_NONE on success, a JSON error constant on encoding error, or JSON_ERROR_NONE - 1 on file writing error

formatSize()

Format a file size in bytes to the greater multiple for display

formatSize(int $size) : string
Parameters
$size : int

In bytes

Return values
string

getMimeType()

Return the mime-type of a file

getMimeType(string $filepath[, string $altfilename = "" ]) : string

The PHP finfo() function doesn't always return the right mime-type, so it tries to read it from OCF containers and to fallback on file extension when the mime-type is obviously too generic (e.g. text/plain, text/xml).

You can provide an alternate filename to force the extension instead of taking the extension of filepath.

Parameters
$filepath : string

An absolute or relative file path

$altfilename : string = ""

Default is ""

Return values
string

A mime-type

getExtension()

Return the extension of a file in lowercase (without point)

getExtension(string $filepath) : string
Parameters
$filepath : string

An absolute or relative file path

Return values
string

replaceFileExtension()

Replace the extension of a file by an other

replaceFileExtension(string $filepath, string $new_extension) : string
Parameters
$filepath : string

An absolute or relative file path

$new_extension : string

New extension (without point)

Return values
string

removeFileExtension()

Remove the extension of a file path (and its point)

removeFileExtension(string $filepath) : string
Parameters
$filepath : string

An absolute or relative file path

Return values
string

bin2hex_encode_file()

Encode a file with bin2hex as an other file

bin2hex_encode_file(string $fsrc, string $fdst) : void
Parameters
$fsrc : string

An absolute or relative file path as source

$fdst : string

An absolute or relative file path as destination

hash_path()

Generates a hash of a file or directory at the given path with the specified algo.

hash_path(string $algo, string $path) : string

If the path is to a single file, it uses hash_file. Otherwise, it recursively loops through all files in a directory to generate the hash of hashes of those files.

Parameters
$algo : string
  • the hash algo
$path : string
  • the path of the folder or file
Tags
see
https://www.php.net/manual/en/function.hash-algos.php
Return values
string

        
On this page

Search results