Overview

Namespaces

  • None
  • Xmf
    • Database
    • Module
      • Helper
    • Template
  • Xoops
    • Auth
    • Core
      • Cache
      • Database
        • Logging
        • Schema
      • Exception
      • Handler
        • Scheme
      • Kernel
        • Dtype
        • Handlers
        • Model
      • Lists
      • Locale
        • Punic
      • Service
        • Contract
      • Session
      • Text
        • Sanitizer
          • Extensions
      • Theme
        • Plugins
    • Form
    • Html
    • Locale
    • Module
      • Helper
      • Plugin

Classes

  • Assets
  • ComposerUtility
  • Events
  • FilterInput
  • FixedGroups
  • HttpRequest
  • Logger
  • MediaUploader
  • MimeTypes
  • PreloadItem
  • Psr0ClassLoader
  • Psr4ClassLoader
  • Random
  • Registry
  • Request
  • Security
  • XoopsTpl
  • Yaml

Interfaces

  • AttributeInterface
  • Overview
  • Namespace
  • Class
  • Tree

Class MediaUploader

XOOPS file uploader

Example of usage:

$allowed_mimetypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png');
$maxfilesize = 50000;
$maxfilewidth = 120;
$maxfileheight = 120;
$uploader = new Xoops\Core\MediaUploader(
     '/home/xoops/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();
}

Direct known subclasses

XoopsMediaUploader
Namespace: Xoops\Core
Package: MediaUploader
Category: Xoops\Core\MediaUploader
Copyright: 2003-2014 XOOPS Project (http://xoops.org)
License: GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
Author: Kazumi Ono (http://www.myweb.ne.jp/, http://jp.xoops.org/)
Author: Taiwen Jiang phppp@users.sourceforge.net
Link: http://xoops.org
Located at oops_lib/Xoops/Core/MediaUploader.php
Methods summary
public
# __construct( string $uploadDir, array $allowedMimeTypes, integer $maxFileSize = 0, integer $maxWidth = null, integer $maxHeight = null )

Constructor

Constructor

Parameters

$uploadDir
upload directory
$allowedMimeTypes
allowed mime types
$maxFileSize
max size
$maxWidth
max width
$maxHeight
max height
public boolean
# fetchMedia( string $media_name, integer $index = null )

Fetch the uploaded file

Fetch the uploaded file

Parameters

$media_name
Name of the file field
$index
Index of the file (if more than one uploaded under that name)

Returns

boolean
public
# setTargetFileName( string $value )

Set the target filename

Set the target filename

Parameters

$value
file name
public
# setPrefix( string $value )

Set the prefix

Set the prefix

Parameters

$value
prefix
public string
# getMediaName( )

Get the uploaded filename

Get the uploaded filename

Returns

string
public string
# getMediaType( )

Get the type of the uploaded file

Get the type of the uploaded file

Returns

string
public integer
# getMediaSize( )

Get the size of the uploaded file

Get the size of the uploaded file

Returns

integer
public string
# getMediaTmpName( )

Get the temporary name that the uploaded file was stored under

Get the temporary name that the uploaded file was stored under

Returns

string
public string
# getSavedFileName( )

Get the saved filename

Get the saved filename

Returns

string
public string
# getSavedDestination( )

Get the destination the file is saved to

Get the destination the file is saved to

Returns

string
public boolean
# upload( integer $chmod = 0644 )

Check the file and copy it to the destination

Check the file and copy it to the destination

Parameters

$chmod
file permissions to set

Returns

boolean
protected boolean
# copyFile( integer $chmod )

Copy the file to its destination

Copy the file to its destination

Parameters

$chmod
file permissions to set

Returns

boolean
public boolean
# checkMaxFileSize( )

Is the file the right size?

Is the file the right size?

Returns

boolean
public boolean
# checkMaxWidth( )

Is the picture the right width?

Is the picture the right width?

Returns

boolean
public boolean
# checkMaxHeight( )

Is the picture the right height?

Is the picture the right height?

Returns

boolean
public boolean
# checkMimeType( )

Check whether or not the uploaded file type is allowed

Check whether or not the uploaded file type is allowed

Returns

boolean
public boolean
# checkImageType( )

Check whether or not the uploaded image type is valid

Check whether or not the uploaded image type is valid

Returns

boolean
public
# sanitizeMultipleExtensions( )

Sanitize executable filename with multiple extensions

Sanitize executable filename with multiple extensions

public
# setErrors( string $error )

Add an error

Add an error

Parameters

$error
message
public array
# getErrors( boolean $ashtml = true )

Get generated errors

Get generated errors

Parameters

$ashtml
Format using HTML?

Returns

array
|string Array of array messages OR HTML string
Properties summary
public boolean $allowUnknownTypes

Flag indicating if unrecognized mimetypes should be allowed (use with precaution ! may lead to security issues )

Flag indicating if unrecognized mimetypes should be allowed (use with precaution ! may lead to security issues )

# false
public string $mediaName
#
public string $mediaType
#
public integer $mediaSize
#
public string $mediaTmpName
#
public string $mediaError
#
public string $mediaRealType
# ''
public string $uploadDir
# ''
public array $allowedMimeTypes
# array()
public array $deniedMimeTypes
# array( 'application/x-httpd-php' )
public integer $maxFileSize
# 0
public integer $maxWidth
#
public integer $maxHeight
#
public string $targetFileName
#
public $prefix
#
public array $errors
# array()
public string $savedDestination
#
public string $savedFileName
#
public boolean $checkImageType
# true
public array $extensionsToBeSanitized
# array( 'php', 'phtml', 'phtm', 'php3', 'php4', 'cgi', 'pl', 'asp', 'php5' )
public array $imageExtensions

extensions needed image check (anti-IE Content-Type XSS)

extensions needed image check (anti-IE Content-Type XSS)

# 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 => 'swf', 14 => 'iff', 15 => 'wbmp', 16 => 'xbm' )
API documentation generated by ApiGen