-
Notifications
You must be signed in to change notification settings - Fork 35
icms_file_MediaUploadHandler
Notice: Wiki was automatic generated from project sources as project API documentation. Do not edit manually!
Upload Media files Example of usage: <code> $allowed_mimetypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png'); $maxfilesize = 50000; $maxfilewidth = 120; $maxfileheight = 120; $uploader = new icms_file_MediaUploadHandler('/home/httpdocs/uploads', $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight); if($uploader->fetchMedia($_POST['uploade_file_name'])) { if(!$uploader->upload()) { echo $uploader->getErrors(); } else { echo '<h4>File uploaded successfully!</h4>' echo 'Saved as: ' . $uploader->getSavedFileName() . '<br />'; echo 'Full path: ' . $uploader->getSavedDestination(); } } else { echo $uploader->getErrors(); } </code>
- Class name: icms_file_MediaUploadHandler
- Namespace:
private bool $allowUnknownTypes = \false
- Visibility: private
private string $mediaName
- Visibility: private
private string $mediaType
- Visibility: private
private string $mediaSize
- Visibility: private
private string $mediaTmpName
- Visibility: private
private string $mediaError
- Visibility: private
private string $mediaRealType
- Visibility: private
private string $uploadDir
- Visibility: private
private array $allowedMimeTypes = array()
- Visibility: private
private string $deniedMimeTypes = array(application/x-httpd-php)
- Visibility: private
private int $maxFileSize
- Visibility: private
private string $maxWidth
- Visibility: private
private string $maxHeight
- Visibility: private
private string $targetFileName
- Visibility: private
private string $prefix
- Visibility: private
private array $errors = array()
- Visibility: private
private string $savedDestination
- Visibility: private
private string $savedFileName
- Visibility: private
private array $extensionToMime = array()
- Visibility: private
private bool $checkImageType = \true
- Visibility: private
private array $extensionsToBeSanitized = array(php, phtml, phtm, php3, php4, cgi, pl, asp, php5)
- Visibility: private
private array $imageExtensions = array(1 => gif, 2 => jpg, 3 => png, 4 => swf, 5 => psd, 6 => bmp, 7 => tif, 8 => tif, 9 => jpc, 10 => jp2, 11 => jpx, 12 => jb2, 13 => swc, 14 => iff, 15 => wbmp, 16 => xbm)
- Visibility: private
mixed icms_file_MediaUploadHandler::__construct(string uploadDir, array allowedMimeTypes, int maxFileSize, int maxWidth, int maxHeight)
Constructor
- Visibility: public
- uploadDir string
- allowedMimeTypes array
- maxFileSize int
- maxWidth int
- maxHeight int
mixed icms_file_MediaUploadHandler::fetchFromURL(string url)
Do same as fetchMedia but from URL
- Visibility: public
- url string
bool icms_file_MediaUploadHandler::fetchMedia(string media_name, int index)
Fetch the uploaded file
- Visibility: public
- media_name string - <p>Name of the file field</p>
- index int - <p>Index of the file (if more than one uploaded under that name)</p>
string icms_file_MediaUploadHandler::getUploadErrorText(int err)
Get Text messages for POST upload errors
- Visibility: private
- err int - <p>error number</p>
mixed icms_file_MediaUploadHandler::setTargetFileName(string value)
Set the target filename
- Visibility: public
- value string
mixed icms_file_MediaUploadHandler::setPrefix(string value, bool unique)
Set the prefix
- Visibility: public
- value string
- unique bool
string icms_file_MediaUploadHandler::getMediaName()
Get the uploaded filename
- Visibility: public
string icms_file_MediaUploadHandler::getMediaType()
Get the type of the uploaded file
- Visibility: public
int icms_file_MediaUploadHandler::getMediaSize()
Get the size of the uploaded file
- Visibility: public
string icms_file_MediaUploadHandler::getMediaTmpName()
Get the temporary name that the uploaded file was stored under
- Visibility: public
string icms_file_MediaUploadHandler::getSavedFileName()
Get the saved filename
- Visibility: public
string icms_file_MediaUploadHandler::getSavedDestination()
Get the destination the file is saved to
- Visibility: public
bool icms_file_MediaUploadHandler::upload(mixed chmod)
Check the file and copy it to the destination
- Visibility: public
- chmod mixed
bool icms_file_MediaUploadHandler::_copyFile(mixed chmod)
Copy the file to its destination
- Visibility: private
- chmod mixed
bool icms_file_MediaUploadHandler::checkMaxFileSize()
Is the file the right size?
- Visibility: public
bool icms_file_MediaUploadHandler::checkMaxWidth()
Is the picture the right width?
- Visibility: public
bool icms_file_MediaUploadHandler::checkMaxHeight()
Is the picture the right height?
- Visibility: public
bool icms_file_MediaUploadHandler::checkMimeType()
Check whether or not the uploaded file type is allowed
- Visibility: public
bool icms_file_MediaUploadHandler::checkImageType()
Check whether or not the uploaded image type is valid
- Visibility: public
mixed icms_file_MediaUploadHandler::sanitizeMultipleExtensions()
Sanitize executable filename with multiple extensions
- Visibility: public
mixed icms_file_MediaUploadHandler::setErrors(string error)
Add an error
- Visibility: public
- error string
array|string icms_file_MediaUploadHandler::getErrors(bool ashtml)
Get generated errors
- Visibility: public
- ashtml bool - <p>Format using HTML?</p>