XOOPS 2.5.6
Final
|
Public Member Functions | |
_copyFile ($chmod) | |
checkImageType () | |
checkMaxFileSize () | |
checkMaxHeight () | |
checkMaxWidth () | |
checkMimeType () | |
fetchMedia ($media_name, $index=null) | |
& | getErrors ($ashtml=true) |
getMediaName () | |
getMediaSize () | |
getMediaTmpName () | |
getMediaType () | |
getSavedDestination () | |
getSavedFileName () | |
sanitizeMultipleExtensions () | |
setErrors ($error) | |
setPrefix ($value) | |
setTargetFileName ($value) | |
upload ($chmod=0644) | |
XoopsMediaUploader ($uploadDir, $allowedMimeTypes, $maxFileSize=0, $maxWidth=null, $maxHeight=null) | |
Public Attributes | |
$allowedMimeTypes = array() | |
$allowUnknownTypes = false | |
$checkImageType = true | |
$deniedMimeTypes | |
$errors = array() | |
$extensionsToBeSanitized | |
$extensionToMime = array() | |
$imageExtensions | |
$maxFileSize = 0 | |
$maxHeight | |
$maxWidth | |
$mediaError | |
$mediaName | |
$mediaRealType = '' | |
$mediaSize | |
$mediaTmpName | |
$mediaType | |
$prefix | |
$savedDestination | |
$savedFileName | |
$targetFileName | |
$uploadDir = '' | |
! Example
include_once 'uploader.php'; $allowed_mimetypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png'); $maxfilesize = 50000; $maxfilewidth = 120; $maxfileheight = 120; $uploader = new XoopsMediaUploader('/home/xoops/uploads', $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight); if ($uploader->fetchMedia($_POST['uploade_file_name'])) { if (!$uploader->upload()) { echo $uploader->getErrors(); } else { echo '
' echo 'Saved as: ' . $uploader->getSavedFileName() . '
'; echo 'Full path: ' . $uploader->getSavedDestination(); } } else { echo $uploader->getErrors(); } Upload Media files
Example of usage: include_once 'uploader.php'; $allowed_mimetypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png'); $maxfilesize = 50000; $maxfilewidth = 120; $maxfileheight = 120; $uploader = new XoopsMediaUploader('/home/xoops/uploads', $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight); if ($uploader->fetchMedia($_POST['uploade_file_name'])) { if (!$uploader->upload()) { echo $uploader->getErrors(); } else { echo '
' echo 'Saved as: ' . $uploader->getSavedFileName() . '
'; echo 'Full path: ' . $uploader->getSavedDestination(); } } else { echo $uploader->getErrors(); }
Definition at line 71 of file uploader.php.
XoopsMediaUploader::_copyFile | ( | $chmod | ) |
Copy the file to its destination
Definition at line 346 of file uploader.php.
References $ext, _ER_UP_FAILEDSAVEFILE, _ER_UP_INVALIDFILENAME, and _ER_UP_SUSPICIOUSREFUSED.
XoopsMediaUploader::checkImageType | ( | ) |
Check whether or not the uploaded image type is valid
Definition at line 463 of file uploader.php.
References _ER_UP_INVALIDIMAGEFILE.
XoopsMediaUploader::checkMaxFileSize | ( | ) |
Is the file the right size?
Definition at line 385 of file uploader.php.
References _ER_UP_FILESIZETOOLARGE.
XoopsMediaUploader::checkMaxHeight | ( | ) |
Is the picture the right height?
Definition at line 423 of file uploader.php.
References _ER_UP_FAILEDFETCHIMAGESIZE, and _ER_UP_FILEHEIGHTTOOLARGE.
XoopsMediaUploader::checkMaxWidth | ( | ) |
Is the picture the right width?
Definition at line 402 of file uploader.php.
References _ER_UP_FAILEDFETCHIMAGESIZE, and _ER_UP_FILEWIDTHTOOLARGE.
XoopsMediaUploader::checkMimeType | ( | ) |
Check whether or not the uploaded file type is allowed
Definition at line 444 of file uploader.php.
References _ER_UP_MIMETYPENOTALLOWED, and _ER_UP_UNKNOWNFILETYPEREJECTED.
XoopsMediaUploader::fetchMedia | ( | $media_name, | |
$index = null |
|||
) |
Fetch the uploaded file
string | $media_name | Name of the file field |
int | $index | Index of the file (if more than one uploaded under that name) |
Definition at line 168 of file uploader.php.
References $ext, $index, _ER_UP_ERROROCCURRED, _ER_UP_FILENAMEEMPTY, _ER_UP_FILENOTFOUND, _ER_UP_INVALIDFILESIZE, _ER_UP_MIMETYPELOAD, and _ER_UP_NOFILEUPLOADED.
& XoopsMediaUploader::getErrors | ( | $ashtml = true | ) |
Get generated errors
bool | $ashtml | Format using HTML? |
Definition at line 512 of file uploader.php.
References $error, $errors, $ret, and _ER_UP_ERRORSRETURNED.
XoopsMediaUploader::getMediaName | ( | ) |
XoopsMediaUploader::getMediaSize | ( | ) |
XoopsMediaUploader::getMediaTmpName | ( | ) |
Get the temporary name that the uploaded file was stored under
Definition at line 274 of file uploader.php.
XoopsMediaUploader::getMediaType | ( | ) |
XoopsMediaUploader::getSavedDestination | ( | ) |
XoopsMediaUploader::getSavedFileName | ( | ) |
XoopsMediaUploader::sanitizeMultipleExtensions | ( | ) |
Sanitize executable filename with multiple extensions
Definition at line 481 of file uploader.php.
References $ext.
XoopsMediaUploader::setErrors | ( | $error | ) |
Add an error
string | $error |
Definition at line 501 of file uploader.php.
References $error.
XoopsMediaUploader::setPrefix | ( | $value | ) |
XoopsMediaUploader::setTargetFileName | ( | $value | ) |
XoopsMediaUploader::upload | ( | $chmod = 0644 | ) |
Check the file and copy it to the destination
Definition at line 304 of file uploader.php.
References _ER_UP_FAILEDOPENDIR, _ER_UP_FAILEDOPENDIRWRITE, and _ER_UP_UPLOADDIRNOTSET.
XoopsMediaUploader::XoopsMediaUploader | ( | $uploadDir, | |
$allowedMimeTypes, | |||
$maxFileSize = 0 , |
|||
$maxWidth = null , |
|||
$maxHeight = null |
|||
) |
Constructor
string | $uploadDir | |
array | $allowedMimeTypes | |
int | $maxFileSize | |
int | $maxWidth | |
int | $maxHeight | |
int | $cmodvalue |
Definition at line 137 of file uploader.php.
References $GLOBALS.
XoopsMediaUploader::$allowedMimeTypes = array() |
Definition at line 85 of file uploader.php.
XoopsMediaUploader::$allowUnknownTypes = false |
Flag indicating if unrecognized mimetypes should be allowed (use with precaution ! may lead to security issues )
Definition at line 77 of file uploader.php.
XoopsMediaUploader::$checkImageType = true |
Definition at line 97 of file uploader.php.
XoopsMediaUploader::$deniedMimeTypes |
Definition at line 86 of file uploader.php.
XoopsMediaUploader::$errors = array() |
Definition at line 93 of file uploader.php.
XoopsMediaUploader::$extensionsToBeSanitized |
Definition at line 98 of file uploader.php.
XoopsMediaUploader::$extensionToMime = array() |
Definition at line 96 of file uploader.php.
XoopsMediaUploader::$imageExtensions |
Definition at line 109 of file uploader.php.
XoopsMediaUploader::$maxFileSize = 0 |
Definition at line 88 of file uploader.php.
XoopsMediaUploader::$maxHeight |
Definition at line 90 of file uploader.php.
XoopsMediaUploader::$maxWidth |
Definition at line 89 of file uploader.php.
XoopsMediaUploader::$mediaError |
Definition at line 82 of file uploader.php.
XoopsMediaUploader::$mediaName |
Definition at line 78 of file uploader.php.
XoopsMediaUploader::$mediaRealType = '' |
Definition at line 83 of file uploader.php.
XoopsMediaUploader::$mediaSize |
Definition at line 80 of file uploader.php.
XoopsMediaUploader::$mediaTmpName |
Definition at line 81 of file uploader.php.
XoopsMediaUploader::$mediaType |
Definition at line 79 of file uploader.php.
XoopsMediaUploader::$prefix |
Definition at line 92 of file uploader.php.
XoopsMediaUploader::$savedDestination |
Definition at line 94 of file uploader.php.
XoopsMediaUploader::$savedFileName |
Definition at line 95 of file uploader.php.
XoopsMediaUploader::$targetFileName |
Definition at line 91 of file uploader.php.
XoopsMediaUploader::$uploadDir = '' |
Definition at line 84 of file uploader.php.