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

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

- Protected Attributes inherited from File

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

Detailed Description

The UploadedFile class.

Represents uploaded file

Constructor & Destructor Documentation

◆ __construct()

__construct ( UploadedFileBase  $uploadedFile,
CKFinder  $app 



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.

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

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.

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

◆ getContents()

getContents ( )

Returns uploaded file contents.

string uploaded file data

◆ getContentsStream()

getContentsStream ( )

Returns contents stream for the uploaded file.


◆ 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.

int upload error

◆ getErrorMessage()

getErrorMessage ( )

Returns the upload error message.

string upload error

◆ getMimeType()

getMimeType ( )

Returns uploaded file MIME type.

◆ getSize()

getSize ( )

Returns uploaded file size in bytes.

int file size in bytes

◆ hasAllowedExtension()

hasAllowedExtension ( )

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

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.

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.

bool true if the file name is hidden

◆ isValid()

isValid ( )

Checks if the file was uploaded properly.

bool true if upload is valid

◆ isValidImage()

isValidImage ( )

Checks if the file is a valid image.

Internally getimagesize is used for validation.

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.

string$datanew file contents

◆ wasRenamed()

wasRenamed ( )

Checks if the file was renamed.

bool true if the file was renamed

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