Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
|
Public Member Functions | |
__construct ( $fileId, Mime $fileMime=null) | |
save ($destinationFolder, $newFileName=null) | |
getFileExtension () | |
addValidateCallback ($callbackName, $callbackObject, $callbackMethod) | |
removeValidateCallback ($callbackName) | |
correctFileNameCase ($fileName) | |
checkMimeType ($validTypes=[]) | |
getUploadedFileName () | |
setAllowCreateFolders ($flag) | |
setAllowRenameFiles ($flag) | |
setFilesDispersion ($flag) | |
setFilenamesCaseSensitivity ($flag) | |
setAllowedExtensions ($extensions=[]) | |
checkAllowedExtension ($extension) | |
Static Public Member Functions | |
static | getCorrectFileName ($fileName) |
static | getNewFileName ($destinationFile) |
static | getDispretionPath ($fileName) |
static | getDispersionPath ($fileName) |
Data Fields | |
const | SINGLE_STYLE = 0 |
const | MULTIPLE_STYLE = 1 |
const | TMP_NAME_EMPTY = 666 |
const | MAX_IMAGE_WIDTH = 4096 |
const | MAX_IMAGE_HEIGHT = 2160 |
Protected Member Functions | |
_afterSave ($result) | |
chmod ($file) | |
_moveFile ($tmpPath, $destPath) | |
_validateFile () | |
Static Protected Member Functions | |
static | _addDirSeparator ($dir) |
Protected Attributes | |
$_file | |
$_fileMimeType | |
$_uploadType | |
$_uploadedFileName | |
$_uploadedFileDir | |
$_allowCreateFolders = true | |
$_allowRenameFiles = false | |
$_enableFilesDispersion = false | |
$_caseInsensitiveFilenames = true | |
$_dispretionPath = null | |
$_fileExists = false | |
$_allowedExtensions = null | |
$_validateCallbacks = [] | |
$_result | |
File upload class
ATTENTION! This class must be used like abstract class and must added validation by protected file extension list to extended class
@api
Definition at line 17 of file Uploader.php.
__construct | ( | $fileId, | |
Mime | $fileMime = null |
||
) |
Init upload
string | array | $fileId | |
\Magento\Framework\File\Mime | null | $fileMime |
Definition at line 168 of file Uploader.php.
|
staticprotected |
Add directory separator
string | $dir |
Definition at line 406 of file Uploader.php.
|
protected |
After save logic
array | $result |
Definition at line 189 of file Uploader.php.
|
protected |
Move files from TMP folder into destination folder
string | $tmpPath | |
string | $destPath |
Definition at line 293 of file Uploader.php.
|
protected |
Validate file before save
Definition at line 308 of file Uploader.php.
addValidateCallback | ( | $callbackName, | |
$callbackObject, | |||
$callbackMethod | |||
) |
Add validation callback model for us in self::_validateFile()
string | $callbackName | |
object | $callbackObject | |
string | $callbackMethod | Method name of $callbackObject. It must have interface (string $tmpFilePath) |
Definition at line 348 of file Uploader.php.
checkAllowedExtension | ( | $extension | ) |
Check if specified extension is allowed
string | $extension |
Definition at line 513 of file Uploader.php.
checkMimeType | ( | $validTypes = [] | ) |
Used to check if uploaded file mime type is valid or not
string[] | $validTypes @access public |
Definition at line 421 of file Uploader.php.
|
protected |
Set access permissions to file.
string | $file |
Definition at line 281 of file Uploader.php.
correctFileNameCase | ( | $fileName | ) |
Convert filename to lowercase in case of case-insensitive file names
string | $fileName |
Definition at line 392 of file Uploader.php.
|
static |
Correct filename with special chars and spaces
string | $fileName |
Definition at line 375 of file Uploader.php.
|
static |
Get dispertion path
string | $fileName |
Definition at line 642 of file Uploader.php.
|
static |
Get dispertion path
string | $fileName |
Definition at line 630 of file Uploader.php.
getFileExtension | ( | ) |
|
static |
Get new file name if the same is already exists
string | $destinationFile |
Definition at line 605 of file Uploader.php.
getUploadedFileName | ( | ) |
Returns a name of uploaded file
@access public
Definition at line 437 of file Uploader.php.
removeValidateCallback | ( | $callbackName | ) |
Delete validation callback model for us in self::_validateFile()
string | $callbackName | @access public |
Definition at line 361 of file Uploader.php.
save | ( | $destinationFolder, | |
$newFileName = null |
|||
) |
Used to save uploaded file into destination folder with original or new file name (if specified).
string | $destinationFolder | |
string | $newFileName |
Definition at line 203 of file Uploader.php.
setAllowCreateFolders | ( | $flag | ) |
Used to set _allowCreateFolders value
bool | $flag | @access public |
Definition at line 449 of file Uploader.php.
setAllowedExtensions | ( | $extensions = [] | ) |
Set allowed extensions
string[] | $extensions |
Definition at line 499 of file Uploader.php.
setAllowRenameFiles | ( | $flag | ) |
Used to set _allowRenameFiles value
bool | $flag | @access public |
Definition at line 462 of file Uploader.php.
setFilenamesCaseSensitivity | ( | $flag | ) |
File names Case-sensitivity setter
bool | $flag |
Definition at line 487 of file Uploader.php.
setFilesDispersion | ( | $flag | ) |
Used to set _enableFilesDispersion value
bool | $flag | @access public |
Definition at line 475 of file Uploader.php.
|
protected |
Definition at line 67 of file Uploader.php.
|
protected |
Definition at line 110 of file Uploader.php.
|
protected |
Definition at line 76 of file Uploader.php.
|
protected |
Definition at line 94 of file Uploader.php.
|
protected |
Definition at line 100 of file Uploader.php.
|
protected |
Definition at line 84 of file Uploader.php.
|
protected |
Definition at line 25 of file Uploader.php.
|
protected |
Definition at line 105 of file Uploader.php.
|
protected |
Definition at line 33 of file Uploader.php.
|
protected |
Definition at line 159 of file Uploader.php.
|
protected |
Definition at line 58 of file Uploader.php.
|
protected |
Definition at line 50 of file Uploader.php.
|
protected |
Definition at line 41 of file Uploader.php.
|
protected |
Definition at line 118 of file Uploader.php.
const MAX_IMAGE_HEIGHT = 2160 |
Maximum Image Height resolution in pixels. For image resizing on client side
Definition at line 151 of file Uploader.php.
const MAX_IMAGE_WIDTH = 4096 |
Maximum Image Width resolution in pixels. For image resizing on client side
Definition at line 144 of file Uploader.php.
const MULTIPLE_STYLE = 1 |
Definition at line 130 of file Uploader.php.
const SINGLE_STYLE = 0 |
#+ File upload type (multiple or single)
Definition at line 128 of file Uploader.php.
const TMP_NAME_EMPTY = 666 |
#- Temp file name empty code
Definition at line 137 of file Uploader.php.