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) | |
![]() | |
__construct ($fileName, CKFinder $app) | |
hasValidFilename () | |
getFilename () | |
getExtension () | |
getExtensions ($newFileName=null) | |
autorename (Backend $backend=null, $path='') | |
isImage () | |
getCache () | |
Protected Attributes | |
$uploadedFile | |
$workingFolder | |
$tempFilePath | |
![]() | |
$fileName | |
$config | |
$app | |
Additional Inherited Members | |
![]() | |
static | isValidName ($fileName, $disallowUnsafeCharacters=true) |
static | secureName ($fileName, $disallowUnsafeCharacters=true, $forceAscii=false) |
static | convertToAscii ($str) |
![]() | |
const | NO_EXTENSION = 'NO_EXT' |
The UploadedFile class.
Represents uploaded file
__construct | ( | UploadedFileBase | $uploadedFile, |
CKFinder | $app | ||
) |
Constructor.
Exception if file upload failed
__destruct | ( | ) |
Destructor: Removes the temporary file, if required.
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 | $backend | target backend |
string | $path | target backend-relative path |
true
if file was renamedmixed | $path |
Reimplemented from File.
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.
true
if the uploaded file contains HTML in the first 1024 bytes getContents | ( | ) |
Returns uploaded file contents.
getContentsStream | ( | ) |
Returns contents stream for the uploaded file.
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.
getErrorMessage | ( | ) |
Returns the upload error message.
getMimeType | ( | ) |
Returns uploaded file MIME type.
getSize | ( | ) |
Returns uploaded file size in bytes.
hasAllowedExtension | ( | ) |
Checks if the file extension is allowed in the target folder.
true
if an extension is allowed in the target folder isAllowedHtmlFile | ( | ) |
Checks if a file with the current extension is allowed to contain any HTML/JS.
true
if a file is allowed to contain HTML chunks isHiddenFile | ( | ) |
Check if the current file name is defined as hidden in configuration settings.
true
if the file name is hidden isValid | ( | ) |
Checks if the file was uploaded properly.
true
if upload is valid isValidImage | ( | ) |
Checks if the file is a valid image.
Internally getimagesize
is used for validation.
true
if the file is a valid image sanitizeFilename | ( | ) |
Sanitizes current file name using options set in Config.
save | ( | $data | ) |
Saves the data as new file contents.
string | $data | new file contents |
wasRenamed | ( | ) |
Checks if the file was renamed.
true
if the file was renamed