CKFinder 3 – PHP Connector Documentation
UploadedFile Class Reference
Inheritance diagram for UploadedFile:
File

Public Member Functions

 __construct (UploadedFileBase $uploadedFile, CKFinder $app)
 
 __destruct ()
 
 isValid ()
 
 sanitizeFilename ()
 
 hasAllowedExtension ()
 
 autorename (Backend $backend=null, $path='')
 
 wasRenamed ()
 
 isHiddenFile ()
 
 getError ()
 
 getErrorMessage ()
 
 getContents ()
 
 getContentsStream ()
 
 getSize ()
 
 getMimeType ()
 
 containsHtml ()
 
 isAllowedHtmlFile ()
 
 isValidImage ()
 
 save ($data)
 
- Public Member Functions inherited from File
 __construct ($fileName, CKFinder $app)
 
 hasValidFilename ()
 
 getFilename ()
 
 getExtension ()
 
 getExtensions ($newFileName=null)
 
 autorename (Backend $backend=null, $path='')
 
 isImage ()
 
 getCache ()
 

Protected Attributes

 $uploadedFile
 
 $workingFolder
 
 $tempFilePath
 
- Protected Attributes inherited from File
 $fileName
 
 $config
 
 $app
 

Additional Inherited Members

- Static Public Member Functions inherited from File
static isValidName ($fileName, $disallowUnsafeCharacters=true)
 
static secureName ($fileName, $disallowUnsafeCharacters=true, $forceAscii=false)
 
static convertToAscii ($str)
 
- Public Attributes inherited from File
const NO_EXTENSION = 'NO_EXT'
 

Detailed Description

The UploadedFile class.

Represents uploaded file

Constructor & Destructor Documentation

◆ __construct()

__construct ( UploadedFileBase  $uploadedFile,
CKFinder  $app 
)

Constructor.

Exceptions

Exception if file upload failed

◆ __destruct()

__destruct ( )

Destructor: Removes the temporary file, if required.

Member Function Documentation

◆ autorename()

autorename ( Backend  $backend = null,
  $path = '' 
)

Renames the current file by adding a number to the file name.

Renaming is done by adding a number in parenthesis provided that the file name does not collide with any other file existing in the target backend/path. For example, if the target backend path contains a file named foo.txt and the current file name is foo.txt, this method will change the current file name to foo(1).txt.

Parameters
Backend$backendtarget backend
string$pathtarget backend-relative path
Returns
bool true if file was renamed
Parameters
mixed$path

Reimplemented from File.

◆ containsHtml()

containsHtml ( )

Detects HTML in the first KB to prevent against a potential security issue with IE/Safari/Opera file type auto detection bug. Returns true if a file contains insecure HTML code at the beginning.

Returns
bool true if the uploaded file contains HTML in the first 1024 bytes

◆ getContents()

getContents ( )

Returns uploaded file contents.

Returns
string uploaded file data

◆ getContentsStream()

getContentsStream ( )

Returns contents stream for the uploaded file.

Returns
resource

◆ getError()

getError ( )

Returns the upload error.

If the upload was successful, the UPLOAD_ERR_OK constant is returned. Otherwise one of the other UPLOAD_ERR_XXX constants is returned.

Returns
int upload error

◆ getErrorMessage()

getErrorMessage ( )

Returns the upload error message.

Returns
string upload error

◆ getMimeType()

getMimeType ( )

Returns uploaded file MIME type.

◆ getSize()

getSize ( )

Returns uploaded file size in bytes.

Returns
int file size in bytes

◆ hasAllowedExtension()

hasAllowedExtension ( )

Checks if the file extension is allowed in the target folder.

Returns
bool true if an extension is allowed in the target folder

◆ isAllowedHtmlFile()

isAllowedHtmlFile ( )

Checks if a file with the current extension is allowed to contain any HTML/JS.

Returns
bool true if a file is allowed to contain HTML chunks

◆ isHiddenFile()

isHiddenFile ( )

Check if the current file name is defined as hidden in configuration settings.

Returns
bool true if the file name is hidden

◆ isValid()

isValid ( )

Checks if the file was uploaded properly.

Returns
bool true if upload is valid

◆ isValidImage()

isValidImage ( )

Checks if the file is a valid image.

Internally getimagesize is used for validation.

Returns
bool true if the file is a valid image

◆ sanitizeFilename()

sanitizeFilename ( )

Sanitizes current file name using options set in Config.

◆ save()

save (   $data)

Saves the data as new file contents.

Parameters
string$datanew file contents

◆ wasRenamed()

wasRenamed ( )

Checks if the file was renamed.

Returns
bool true if the file was renamed

The documentation for this class was generated from the following file: