Phpxforms documentation

FileApiPhp extends FileApi
in package

File interaction throughout PHP

Table of Contents

Properties

$mode  : int
$msgs  : array<string, string>
$error  : string
$location  : string
$path  : string

Methods

__construct()  : mixed
clonePost()  : bool
Copy file to specific array space
copy()  : bool
Copy file or directory
createDir()  : bool
Create directory
createFile()  : bool
Create file
cropPath()  : string
Remove current $path from inserted path
delete()  : bool
Delete file or directory
downloadFile()  : bool
Download file to client
escape()  : string
Escape filename and add quotes
exist()  : bool
File exists
fakeUpload()  : void
Setup $_FILE input
filterPath()  : string
Remove /../ up directory from url
fixPath()  : string
Add DIRECTORY_SEPARATOR
getError()  : string
Return last error message
getMime()  : string
Get file MIME type
getPath()  : string
Return current path
getSize()  : int
Get file size
getUpload()  : mixed
Get info form $_FILES
getUrlData()  : string|null
Get file with CURL
isUpload()  : bool
Check if uploaded file is ok
isWritable()  : bool
Is it possible to write into filename
loadFiles()  : array<string, array{NAME: string, DATE: int, SIZE: int, MIME: string}>
Get list of files in directory
makePath()  : string
Return full formatted path with $dir
move()  : bool
Move (rename) file or directory
rename()  : bool
Rename file
setPath()  : bool
Set current path if exists
setUpload()  : void
Set value in $_FILES
upload()  : bool
File upload. Error message is from isUpload
dirDelete()  : bool
Delete directory
dirMake()  : bool
Create directory
fileCopy()  : bool
DirOld for TMP file
fileDelete()  : bool
Delete file
getMsg()  : string
Get message text
processAction()  : bool
Process action form Copy and Move
uniRename()  : bool
Rename file or directory

Properties

$mode

public static int $mode = 0777

Linux rights for directories

$msgs

public static array<string, string> $msgs = ['FILE' => 'Soubor', 'DIR' => 'Složka', 'NO_UPLOAD' => 'Nebyl zadán soubor pro nahrání.', 'UPLOAD_MAX_SIZE' => 'Soubor %s překročil maximální velikost.', 'UPLOAD_STOPPED' => 'Nahrávání souboru %s bylo přerušeno.', 'UPLOAD_ERROR' => 'Soubor %1$s nelze nahrát (chyba %2$d).', 'NO_RIGHTS' => 'Nemáte právo zápisu do: %s.', 'NO_NAME' => 'Nebyl zadán nový název.', 'EXIST' => ' %s již existuje.', 'NOT_EMPTY' => ' %s není prázdný.', 'NOT_FOUND' => ' %s nenalezena.', 'NOT_MOVE' => ' %s nelze zkopírovat.', 'NOT_COPY' => ' %s nelze přesunout.', 'NOT_RENAME' => ' %s nelze přejmenovat.', 'NOT_DELETE' => ' %s nelze odstranit.', 'CURL_ERROR' => 'Curl error: %d', 'GENERAL_ERROR' => 'General error: %s']

$location

protected string $location

Methods

__construct()

public __construct(string $loc) : mixed
Parameters
$loc : string
Tags
throws
InvalidArgumentException

clonePost()

Copy file to specific array space

public clonePost(string $fromMark, array<int, mixed>|int|null $fromLevels, string $toMark, array<int, mixed>|int|null $toLevels) : bool
Parameters
$fromMark : string
$fromLevels : array<int, mixed>|int|null
$toMark : string
$toLevels : array<int, mixed>|int|null
Return values
bool

copy()

Copy file or directory

public copy(string $dirOld, string $dirNew[, string|null $fileOld = null ][, string|null $fileNew = null ]) : bool
Parameters
$dirOld : string
$dirNew : string
$fileOld : string|null = null
$fileNew : string|null = null
Return values
bool

createDir()

Create directory

public createDir(string $dir) : bool
Parameters
$dir : string
Return values
bool

createFile()

Create file

public createFile(string $dir, string $file, string $data[, bool $replace = false ]) : bool
Parameters
$dir : string
$file : string
$data : string
$replace : bool = false
Return values
bool

cropPath()

Remove current $path from inserted path

public cropPath(string $dir) : string
Parameters
$dir : string
Return values
string

delete()

Delete file or directory

public delete(string $dir[, string|null $file = null ]) : bool
Parameters
$dir : string
$file : string|null = null
Return values
bool

downloadFile()

Download file to client

public downloadFile(string $dir, string $file[, bool $stream = false ]) : bool
Parameters
$dir : string
$file : string
$stream : bool = false
Return values
bool

escape()

Escape filename and add quotes

public static escape(string $value[, string $quote = "'" ]) : string
Parameters
$value : string
$quote : string = "'"
Return values
string

exist()

File exists

public exist(string $dir[, string|null $file = null ][, bool $caseSensitive = false ]) : bool
Parameters
$dir : string
$file : string|null = null
$caseSensitive : bool = false
Return values
bool

fakeUpload()

Setup $_FILE input

public fakeUpload(string $input, string $filePath, string $name[, int|null $id = null ]) : void
Parameters
$input : string
$filePath : string
$name : string
$id : int|null = null
Tags
throws
InvalidArgumentException

filterPath()

Remove /../ up directory from url

public filterPath(string $dir) : string
Parameters
$dir : string
Return values
string

fixPath()

Add DIRECTORY_SEPARATOR

public fixPath(string $dir[, bool $isDir = true ]) : string
Parameters
$dir : string
$isDir : bool = true
Return values
string

getError()

Return last error message

public getError() : string
Return values
string

getMime()

Get file MIME type

public getMime(string $url) : string
Parameters
$url : string
Return values
string

getPath()

Return current path

public getPath() : string
Return values
string

getSize()

Get file size

public getSize(string $url) : int
Parameters
$url : string
Return values
int

getUpload()

Get info form $_FILES

public getUpload(string $input, string $type[, int|null $id = null ]) : mixed
Parameters
$input : string
$type : string
$id : int|null = null

getUrlData()

Get file with CURL

public getUrlData(string $url) : string|null
Parameters
$url : string
Return values
string|null

isUpload()

Check if uploaded file is ok

public isUpload(string $input[, int|null $id = null ][, bool $emptyIsOk = false ]) : bool
Parameters
$input : string
$id : int|null = null
$emptyIsOk : bool = false
Return values
bool

isWritable()

Is it possible to write into filename

public isWritable(string $url) : bool
Parameters
$url : string
Return values
bool

loadFiles()

Get list of files in directory

public loadFiles([string $dir = '' ]) : array<string, array{NAME: string, DATE: int, SIZE: int, MIME: string}>
Parameters
$dir : string = ''
Return values
array<string, array{NAME: string, DATE: int, SIZE: int, MIME: string}>

makePath()

Return full formatted path with $dir

public makePath(string $dir[, bool $isDir = true ]) : string
Parameters
$dir : string
$isDir : bool = true
Return values
string

move()

Move (rename) file or directory

public move(string $dirOld, string $dirNew[, string|null $fileOld = null ][, string|null $fileNew = null ]) : bool
Parameters
$dirOld : string
$dirNew : string
$fileOld : string|null = null
$fileNew : string|null = null
Return values
bool

rename()

Rename file

public rename(string $dir, string $oldFile, string $newFile) : bool
Parameters
$dir : string
$oldFile : string
$newFile : string
Return values
bool

setPath()

Set current path if exists

public setPath(string $dir) : bool
Parameters
$dir : string
Return values
bool

setUpload()

Set value in $_FILES

public setUpload(string $input, string $type, mixed $val[, int|null $id = null ]) : void
Parameters
$input : string
$type : string
$val : mixed
$id : int|null = null

upload()

File upload. Error message is from isUpload

public upload(string $input, int|null $id, string $dir[, string|null $file = null ][, bool $copy = false ]) : bool
Parameters
$input : string
$id : int|null
$dir : string
$file : string|null = null
$copy : bool = false
Return values
bool

dirDelete()

Delete directory

protected dirDelete(string $dir) : bool
Parameters
$dir : string
Return values
bool

dirMake()

Create directory

protected dirMake(string $dir) : bool
Parameters
$dir : string
Return values
bool

fileCopy()

DirOld for TMP file

protected fileCopy(string|null $dirOld, string $dirNew, string $fileOld, string $fileNew) : bool
Parameters
$dirOld : string|null
$dirNew : string
$fileOld : string
$fileNew : string
Return values
bool

fileDelete()

Delete file

protected fileDelete(string $dir, string $file) : bool
Parameters
$dir : string
$file : string
Return values
bool

getMsg()

Get message text

protected getMsg(string $msg[, string|int|null $param = null ][, string|null $type = null ][, int|null $num = null ]) : string
Parameters
$msg : string
$param : string|int|null = null
$type : string|null = null
$num : int|null = null
Return values
string

processAction()

Process action form Copy and Move

protected processAction(string $dirOld, string $dirNew, string|null $fileOld, string|null $fileNew[, bool $copy = false ]) : bool
Parameters
$dirOld : string
$dirNew : string
$fileOld : string|null
$fileNew : string|null
$copy : bool = false
Return values
bool

uniRename()

Rename file or directory

protected uniRename(string $dirOld, string $dirNew, string|null $fileOld, string|null $fileNew) : bool
Parameters
$dirOld : string
$dirNew : string
$fileOld : string|null
$fileNew : string|null
Return values
bool

        
On this page

Search results