API - XOOPS 2.5.11 Beta 2
By monxoops.fr
|
Public Member Functions | |
__construct ($uploadDir, $allowedMimeTypes, $maxFileSize=0, $maxWidth=null, $maxHeight=null, $randomFilename=false) | |
return_bytes ($size_str) | |
countMedia ($media_name) | |
fetchMedia ($media_name, $index=null) | |
setTargetFileName ($value) | |
setPrefix ($value) | |
getMediaName () | |
getMediaType () | |
getMediaSize () | |
getMediaTmpName () | |
getSavedFileName () | |
getSavedDestination () | |
upload ($chmod=0644) | |
_copyFile ($chmod) | |
checkMaxFileSize () | |
checkMaxWidth () | |
checkMaxHeight () | |
checkMimeType () | |
checkImageType () | |
sanitizeMultipleExtensions () | |
setErrors ($error) | |
& | getErrors ($ashtml=true) |
Data Fields | |
$allowUnknownTypes = false | |
$mediaName | |
$mediaType | |
$mediaSize | |
$mediaTmpName | |
$mediaError | |
$mediaRealType = '' | |
$uploadDir = '' | |
$allowedMimeTypes = array() | |
$deniedMimeTypes | |
$maxFileSize = 0 | |
$maxWidth | |
$maxHeight | |
$targetFileName | |
$prefix | |
$errors = array() | |
$savedDestination | |
$savedFileName | |
$extensionToMime = array() | |
$checkImageType = true | |
$extensionsToBeSanitized | |
$imageExtensions | |
$randomFilename = false | |
Protected Member Functions | |
arrayPushIfPositive ($set, $value) | |
Upload Media files
Example of usage (single file): include_once 'uploader.php'; $allowed_mimetypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png'); $maxfilesize = 50000; $maxfilewidth = 120; $maxfileheight = 120; $randomFilename = true; $uploader = new XoopsMediaUploader('/home/xoops/uploads', $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight, $randomFilename); if ($uploader->fetchMedia('single_file_name')) { if (!$uploader->upload()) { echo $uploader->getErrors(); } else { echo '
' echo 'Saved as: ' . $uploader->getSavedFileName() . '
'; echo 'Full path: ' . $uploader->getSavedDestination(); } } else { echo $uploader->getErrors(); }
Example of usage (multiple file): include_once 'uploader.php'; $allowed_mimetypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png'); $maxfilesize = 50000; $maxfilewidth = 120; $maxfileheight = 120; $randomFilename = true; $uploader = new XoopsMediaUploader('/home/xoops/uploads', $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight, $randomFilename); for ($i = 0; $i < $uploader->countMedia('multiple_file_name'); $i++) { if ($uploader->fetchMedia('multiple_file_name')) { if (!$uploader->upload()) { echo $uploader->getErrors(); } else { echo '
' echo 'Saved as: ' . $uploader->getSavedFileName() . '
'; echo 'Full path: ' . $uploader->getSavedDestination(); } } else { echo $uploader->getErrors(); } }
__construct | ( | $uploadDir, | |
$allowedMimeTypes, | |||
$maxFileSize = 0 , |
|||
$maxWidth = null , |
|||
$maxHeight = null , |
|||
$randomFilename = false |
|||
) |
Constructor
string | $uploadDir | |
array | $allowedMimeTypes | |
int | $maxFileSize | |
int | $maxWidth | |
int | $maxHeight | |
bool | $randomFilename |
_copyFile | ( | $chmod | ) |
Copy the file to its destination
$chmod |
|
protected |
Push value onto set. Used in max file size calculation to eliminate -1 (unlimited) ini values
array | $set | array of values |
int | $value | value to push |
checkImageType | ( | ) |
Check whether or not the uploaded image type is valid
checkMaxFileSize | ( | ) |
Is the file the right size?
checkMaxHeight | ( | ) |
Is the picture the right height?
checkMaxWidth | ( | ) |
Is the picture the right width?
checkMimeType | ( | ) |
Check whether or not the uploaded file type is allowed
countMedia | ( | $media_name | ) |
Count the uploaded files (in case of miltiple upload)
string | $media_name | Name of the file field |
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) |
& getErrors | ( | $ashtml = true | ) |
Get generated errors
bool | $ashtml | Format using HTML? |
getMediaName | ( | ) |
Get the uploaded filename
getMediaSize | ( | ) |
Get the size of the uploaded file
getMediaTmpName | ( | ) |
Get the temporary name that the uploaded file was stored under
getMediaType | ( | ) |
Get the type of the uploaded file
getSavedDestination | ( | ) |
Get the destination the file is saved to
getSavedFileName | ( | ) |
Get the saved filename
return_bytes | ( | $size_str | ) |
converts memory/file sizes as defined in php.ini to bytes
$size_str |
sanitizeMultipleExtensions | ( | ) |
Sanitize executable filename with multiple extensions
setErrors | ( | $error | ) |
Add an error
string | $error |
setPrefix | ( | $value | ) |
Set the prefix
string | $value |
setTargetFileName | ( | $value | ) |
Set the target filename
string | $value |
upload | ( | $chmod = 0644 | ) |
Check the file and copy it to the destination
int | $chmod |
$allowedMimeTypes = array() |
$allowUnknownTypes = false |
Flag indicating if unrecognized mimetypes should be allowed (use with precaution ! may lead to security issues )
$deniedMimeTypes |
$errors = array() |
$extensionsToBeSanitized |
$extensionToMime = array() |
$imageExtensions |
$maxFileSize = 0 |
$maxHeight |
$maxWidth |
$mediaError |
$mediaName |
$mediaRealType = '' |
$mediaSize |
$mediaTmpName |
$mediaType |
$prefix |
$randomFilename = false |
$savedDestination |
$savedFileName |
$targetFileName |
$uploadDir = '' |