PHP Class PMA\libraries\File

Datei anzeigen Open project: phpmyadmin/phpmyadmin Class Usage Examples

Public Properties

Property Type Description
$_charset charset of file
$_chunk_size size of chunk to read with every step
$_compression type of compression
$_content the content
$_decompress whether to decompress content before returning
$_error_message the error message
$_handle file handle
$_is_temp whether the file is temporary or not
$_name the temporary file name
$_offset integer

Public Methods

Method Description
__construct ( boolean | string $name = false ) constructor
__destruct ( ) destructor
checkTblChangeForm ( string $key, string $rownumber ) : boolean checks the superglobals provided if the tbl_change form is submitted and uses the submitted/selected file
checkUploadedFile ( ) : boolean If we are on a server with open_basedir, we must move the file before opening it. The FAQ 1.11 explains how to create the "./tmp" directory - if needed
cleanUp ( ) : boolean deletes file if it is temporary, usually from a moved upload file
close ( ) : void Closes the file
delete ( ) : boolean deletes the file
eof ( ) : boolean Checks whether we've reached end of file
errorUnsupported ( ) : void Sets error message for unsupported compression.
fetchUploadedFromTblChangeRequestMultiple ( array $file, string $rownumber, string $key ) : array strips some dimension from the multi-dimensional array from $_FILES
getCharset ( ) : string Returns the character set of the file
getChunkSize ( ) : integer Returns the chunk size
getCompression ( ) : string Returns compression used by file.
getContent ( ) : string | false Gets file content
getContentLength ( ) : integer Returns the length of the content in the file
getError ( ) : Message | null Returns possible error message.
getHandle ( ) : resource Returns the file handle
getName ( ) : string accessor
getOffset ( ) : integer Returns the offset
getRawContent ( ) : string | false Gets file content
isError ( ) : boolean Checks whether there was any error.
isReadable ( ) : boolean Checks whether file can be read.
isTemp ( boolean $is_temp = null ) : boolean checks or sets the temp flag for this file file objects with temp flags are deleted with object destruction
isUploaded ( ) : boolean Whether file is uploaded.
open ( ) : boolean Attempts to open the file.
openZip ( string | null $specific_entry = null ) : boolean Opens file from zip
read ( integer $size ) : string Reads data from file
setCharset ( string $charset ) : void Sets the character set of the file
setChunkSize ( integer $chunk_size ) : void Sets the chunk size
setDecompressContent ( boolean $decompress ) : void Sets whether the content should be decompressed before returned
setHandle ( object $handle ) : void Sets the file handle
setLocalSelectedFile ( string $name ) : boolean Sets named file to be read from UploadDir.
setName ( string $name ) : void accessor
setSelectedFromTblChangeRequest ( string $key, string $rownumber = null ) : boolean sets the name if the file to the one selected in the tbl_change form
setUploadedFile ( string $name ) : boolean Initializes object from uploaded file.
setUploadedFromTblChangeRequest ( string $key, string $rownumber ) : boolean Loads uploaded file from table change request.

Protected Methods

Method Description
detectCompression ( ) : string | false Detects what compression the file uses

Method Details

__construct() public method

constructor
public __construct ( boolean | string $name = false )
$name boolean | string file name or false

__destruct() public method

destructor
See also: File::cleanUp()
public __destruct ( )

checkTblChangeForm() public method

checks the superglobals provided if the tbl_change form is submitted and uses the submitted/selected file
public checkTblChangeForm ( string $key, string $rownumber ) : boolean
$key string the md5 hash of the column name
$rownumber string number of row to process
return boolean success

checkUploadedFile() public method

If we are on a server with open_basedir, we must move the file before opening it. The FAQ 1.11 explains how to create the "./tmp" directory - if needed
public checkUploadedFile ( ) : boolean
return boolean whether uploaded file is fine or not

cleanUp() public method

deletes file if it is temporary, usually from a moved upload file
public cleanUp ( ) : boolean
return boolean success

close() public method

Closes the file
public close ( ) : void
return void

delete() public method

deletes the file
public delete ( ) : boolean
return boolean success

detectCompression() protected method

Detects what compression the file uses
protected detectCompression ( ) : string | false
return string | false false on error, otherwise string MIME type of compression, none for none

eof() public method

Checks whether we've reached end of file
public eof ( ) : boolean
return boolean

errorUnsupported() public method

Sets error message for unsupported compression.
public errorUnsupported ( ) : void
return void

fetchUploadedFromTblChangeRequestMultiple() public method

$file['name']['multi_edit'][$rownumber][$key] = [value] $file['type']['multi_edit'][$rownumber][$key] = [value] $file['size']['multi_edit'][$rownumber][$key] = [value] $file['tmp_name']['multi_edit'][$rownumber][$key] = [value] $file['error']['multi_edit'][$rownumber][$key] = [value] becomes: $file['name'] = [value] $file['type'] = [value] $file['size'] = [value] $file['tmp_name'] = [value] $file['error'] = [value]
public fetchUploadedFromTblChangeRequestMultiple ( array $file, string $rownumber, string $key ) : array
$file array the array
$rownumber string number of row to process
$key string key to process
return array

getCharset() public method

Returns the character set of the file
public getCharset ( ) : string
return string character set of the file

getChunkSize() public method

Returns the chunk size
public getChunkSize ( ) : integer
return integer the chunk size

getCompression() public method

Returns compression used by file.
public getCompression ( ) : string
return string MIME type of compression, none for none

getContent() public method

Gets file content
public getContent ( ) : string | false
return string | false the binary file content as a string, or false if no content

getContentLength() public method

Returns the length of the content in the file
public getContentLength ( ) : integer
return integer the length of the file content

getError() public method

Returns possible error message.
public getError ( ) : Message | null
return Message | null error message

getHandle() public method

Returns the file handle
public getHandle ( ) : resource
return resource file handle

getName() public method

accessor
public getName ( ) : string
return string File::$_name

getOffset() public method

Returns the offset
public getOffset ( ) : integer
return integer the offset

getRawContent() public method

Gets file content
public getRawContent ( ) : string | false
return string | false the binary file content, or false if no content

isError() public method

Checks whether there was any error.
public isError ( ) : boolean
return boolean whether an error occurred or not

isReadable() public method

Checks whether file can be read.
public isReadable ( ) : boolean
return boolean whether the file is readable or not

isTemp() public method

checks or sets the temp flag for this file file objects with temp flags are deleted with object destruction
public isTemp ( boolean $is_temp = null ) : boolean
$is_temp boolean sets the temp flag
return boolean File::$_is_temp

isUploaded() public method

Whether file is uploaded.
public isUploaded ( ) : boolean
return boolean

open() public method

Attempts to open the file.
public open ( ) : boolean
return boolean

openZip() public method

Opens file from zip
public openZip ( string | null $specific_entry = null ) : boolean
$specific_entry string | null Entry to open
return boolean

read() public method

Reads data from file
public read ( integer $size ) : string
$size integer Number of bytes to read
return string

setCharset() public method

Sets the character set of the file
public setCharset ( string $charset ) : void
$charset string character set of the file
return void

setChunkSize() public method

Sets the chunk size
public setChunkSize ( integer $chunk_size ) : void
$chunk_size integer the chunk size
return void

setDecompressContent() public method

Sets whether the content should be decompressed before returned
public setDecompressContent ( boolean $decompress ) : void
$decompress boolean whether to decompress
return void

setHandle() public method

Sets the file handle
public setHandle ( object $handle ) : void
$handle object file handle
return void

setLocalSelectedFile() public method

Sets named file to be read from UploadDir.
public setLocalSelectedFile ( string $name ) : boolean
$name string file name
return boolean success

setName() public method

accessor
public setName ( string $name ) : void
$name string file name
return void

setSelectedFromTblChangeRequest() public method

sets the name if the file to the one selected in the tbl_change form
public setSelectedFromTblChangeRequest ( string $key, string $rownumber = null ) : boolean
$key string the md5 hash of the column name
$rownumber string number of row to process
return boolean success

setUploadedFile() public method

Initializes object from uploaded file.
public setUploadedFile ( string $name ) : boolean
$name string name of file uploaded
return boolean success

setUploadedFromTblChangeRequest() public method

Loads uploaded file from table change request.
public setUploadedFromTblChangeRequest ( string $key, string $rownumber ) : boolean
$key string the md5 hash of the column name
$rownumber string number of row to process
return boolean success

Property Details

$_charset public_oe property

charset of file
public $_charset

$_chunk_size public_oe property

size of chunk to read with every step
public $_chunk_size

$_compression public_oe property

type of compression
public $_compression

$_content public_oe property

the content
public $_content

$_decompress public_oe property

whether to decompress content before returning
public $_decompress

$_error_message public_oe property

the error message
public $_error_message

$_handle public_oe property

file handle
public $_handle

$_is_temp public_oe property

whether the file is temporary or not
public $_is_temp

$_name public_oe property

the temporary file name
public $_name

$_offset public_oe property

public int $_offset
return integer