XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
XoopsMediaUploader Class Reference

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 = ''
 

Detailed Description

! 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 '

File uploaded successfully!

' 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 '

File uploaded successfully!

' echo 'Saved as: ' . $uploader->getSavedFileName() . '
'; echo 'Full path: ' . $uploader->getSavedDestination(); } } else { echo $uploader->getErrors(); }

Definition at line 71 of file uploader.php.

Member Function Documentation

XoopsMediaUploader::_copyFile (   $chmod)

Copy the file to its destination

Returns
bool

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

Returns
bool

Definition at line 463 of file uploader.php.

References _ER_UP_INVALIDIMAGEFILE.

XoopsMediaUploader::checkMaxFileSize ( )

Is the file the right size?

Returns
bool

Definition at line 385 of file uploader.php.

References _ER_UP_FILESIZETOOLARGE.

XoopsMediaUploader::checkMaxHeight ( )

Is the picture the right height?

Returns
bool

Definition at line 423 of file uploader.php.

References _ER_UP_FAILEDFETCHIMAGESIZE, and _ER_UP_FILEHEIGHTTOOLARGE.

XoopsMediaUploader::checkMaxWidth ( )

Is the picture the right width?

Returns
bool

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

Returns
bool

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

Parameters
string$media_nameName of the file field
int$indexIndex of the file (if more than one uploaded under that name)
Returns
bool

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

Parameters
bool$ashtmlFormat using HTML?
Returns
array |string Array of array messages OR HTML string

Definition at line 512 of file uploader.php.

References $error, $errors, $ret, and _ER_UP_ERRORSRETURNED.

XoopsMediaUploader::getMediaName ( )

Get the uploaded filename

Returns
string

Definition at line 244 of file uploader.php.

XoopsMediaUploader::getMediaSize ( )

Get the size of the uploaded file

Returns
int

Definition at line 264 of file uploader.php.

XoopsMediaUploader::getMediaTmpName ( )

Get the temporary name that the uploaded file was stored under

Returns
string

Definition at line 274 of file uploader.php.

XoopsMediaUploader::getMediaType ( )

Get the type of the uploaded file

Returns
string

Definition at line 254 of file uploader.php.

XoopsMediaUploader::getSavedDestination ( )

Get the destination the file is saved to

Returns
string

Definition at line 294 of file uploader.php.

XoopsMediaUploader::getSavedFileName ( )

Get the saved filename

Returns
string

Definition at line 284 of file uploader.php.

XoopsMediaUploader::sanitizeMultipleExtensions ( )

Sanitize executable filename with multiple extensions

Definition at line 481 of file uploader.php.

References $ext.

XoopsMediaUploader::setErrors (   $error)

Add an error

Parameters
string$error

Definition at line 501 of file uploader.php.

References $error.

XoopsMediaUploader::setPrefix (   $value)

Set the prefix

Parameters
string$value

Definition at line 234 of file uploader.php.

XoopsMediaUploader::setTargetFileName (   $value)

Set the target filename

Parameters
string$value

Definition at line 224 of file uploader.php.

XoopsMediaUploader::upload (   $chmod = 0644)

Check the file and copy it to the destination

Returns
bool

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

Parameters
string$uploadDir
array$allowedMimeTypes
int$maxFileSize
int$maxWidth
int$maxHeight
int$cmodvalue

Definition at line 137 of file uploader.php.

References $GLOBALS.

Member Data Documentation

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
Initial value:
= array(
'application/x-httpd-php')

Definition at line 86 of file uploader.php.

XoopsMediaUploader::$errors = array()

Definition at line 93 of file uploader.php.

XoopsMediaUploader::$extensionsToBeSanitized
Initial value:
= array(
'php' ,
'phtml' ,
'phtm' ,
'php3' ,
'php4' ,
'cgi' ,
'pl' ,
'asp' ,
'php5')

Definition at line 98 of file uploader.php.

XoopsMediaUploader::$extensionToMime = array()

Definition at line 96 of file uploader.php.

XoopsMediaUploader::$imageExtensions
Initial value:
= 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')

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.


The documentation for this class was generated from the following file: