HTTP_Upload
[ class tree: HTTP_Upload ] [ index: HTTP_Upload ] [ all elements ]

Class: HTTP_Upload_File

Source Location: /HTTP_Upload-1.0.0b4/HTTP/Upload/File.php

Class Overview

PEAR
   |
   --HTTP_Upload_Error
      |
      --HTTP_Upload_File

This class provides functions to work with the uploaded file


Author(s):

Variables

Methods


Inherited Variables

Inherited Methods

Class: HTTP_Upload_Error

HTTP_Upload_Error::HTTP_Upload_Error()
PHP4 Constructor
HTTP_Upload_Error::__construct()
PHP5 Constructor
HTTP_Upload_Error::errorCode()
returns the error code
HTTP_Upload_Error::raiseError()
Overwrites the PEAR::raiseError method
HTTP_Upload_Error::_loadLanguage()
Loads language strings into error codes variable

Class Details

[line 19]
This class provides functions to work with the uploaded file


[ Top ]


Class Variables

$mode_name_selected =  false

[line 31]

If user haven't selected a mode, by default 'safe' will be used
  • Access: protected

Type:   boolean


[ Top ]

$upload = array()

[line 25]

Assoc array with file properties
  • Access: protected

Type:   array


[ Top ]

$_chmod =  HTTP_UPLOAD_DEFAULT_CHMOD

[line 59]

Contains the desired chmod for uploaded files
  • Access: protected

Type:   int


[ Top ]

$_extensionsCaseSensitive =  true

[line 53]

Whether to use case-sensitive extension checks or not

Type:   bool


[ Top ]

$_extensionsCheck = array('php', 'phtm', 'phtml', 'php3', 'inc')

[line 40]

It's a common security risk in pages who has the upload dir under the document root (remember the hack of the Apache web?)

Type:   array


[ Top ]

$_extensionsMode =  'deny'

[line 46]


Type:   string


[ Top ]



Method Detail

HTTP_Upload_File (Constructor)   [line 138]

HTTP_Upload_File HTTP_Upload_File( [ $name = null], [ $tmp = null], [ $formname = null], [ $type = null], [ $size = null], [ $error = null], [ $lang = null], [ $chmod = HTTP_UPLOAD_DEFAULT_CHMOD], [ $allowMulti = false])

PHP4 Constructor

Parameters:

   $name   — 
   $tmp   — 
   $formname   — 
   $type   — 
   $size   — 
   $error   — 
   $lang   — 
   $chmod   — 
   $allowMulti   — 

[ Top ]

__construct (Constructor)   [line 73]

HTTP_Upload_File __construct( [string $name = null], [string $tmp = null], [string $formname = null], [string $type = null], [string $size = null], [string $error = null], [string $lang = null], [ $chmod = HTTP_UPLOAD_DEFAULT_CHMOD], [bool $allowMulti = false])

PHP5 Constructor
  • Access: public

Overrides HTTP_Upload_Error::__construct() (PHP5 Constructor)

Parameters:

string   $name   —  destination file name
string   $tmp   —  temp file name
string   $formname   —  name of the form
string   $type   —  Mime type of the file
string   $size   —  size of the file
string   $error   —  error on upload
string   $lang   —  used language for errormessages
bool   $allowMulti   —  allow for checking multiple extensions in same filename
   $chmod   — 

[ Top ]

addValidExtension   [line 443]

void addValidExtension( string $ext)

Adds an extension to the previously set list of valid extensions
  • Access: public

Parameters:

string   $ext   — 

[ Top ]

errorMsg   [line 391]

string errorMsg( )

Returns a error message, if a error occured

(deprecated) Use getMessage() instead

  • Return: a Error message
  • Access: public

[ Top ]

getMessage   [line 400]

string getMessage( )

Returns a error message, if a error occured
  • Return: a Error message
  • Access: public

[ Top ]

getProp   [line 378]

mixed getProp( [string $name = null])

Retrive properties of the uploaded file

Parameters:

string   $name   —  The property name. When null an assoc array with all the properties will be returned

[ Top ]

getValidExtensions   [line 410]

array getValidExtensions( )

Returns an array with all valid file extensions.
  • Return: Array of extensions without dot.
  • Access: public

[ Top ]

hasError   [line 287]

bool hasError( )

Some error occured during upload (most common due a file size problem, like max size exceeded or 0 bytes long).
  • Return: If there were errors submitting the file (probably because the file excess the max permitted file size)
  • Access: public

[ Top ]

hasValidExtension   [line 452]

bool hasValidExtension( )

Does this file object have a valid extension?
  • Access: public

[ Top ]

isMissing   [line 273]

bool isMissing( )

User haven't submit a file
  • Return: If the user submitted a file or not
  • Access: public

[ Top ]

isValid   [line 260]

bool isValid( )

The upload was valid
  • Return: If the file was submitted correctly
  • Access: public

[ Top ]

moveTo   [line 302]

mixed moveTo( string $dir, [bool $overwrite = true])

Moves the uploaded file to its destination directory.
  • Return: True on success or PEAR_Error object on error
  • Access: public

Parameters:

string   $dir   —  Destination directory
bool   $overwrite   —  Overwrite if destination file exists?

[ Top ]

nameToSafe   [line 244]

string nameToSafe( $name, [int $maxlen = 250], string $file)

Format a file name to be safe

Parameters:

string   $file   —  The string file name
int   $maxlen   —  Maximun permited string lenght
   $name   — 

[ Top ]

nameToSeq   [line 191]

void nameToSeq( string $dir)

Sequence file names in the form: userGuide[1].pdf, userGuide[2].pdf ...
  • Access: public

Parameters:

string   $dir   —  Destination directory

[ Top ]

nameToUniq   [line 230]

void nameToUniq( )

Unique file names in the form: 9022210413b75410c28bef.html

[ Top ]

setName   [line 154]

string setName( string $mode, [string $prepend = null], [string $append = null])

Sets the name of the destination file
  • Return: The modified name of the destination file
  • Access: public

Parameters:

string   $mode   —  A valid mode: 'uniq', 'seq', 'safe' or 'real' or a file name
string   $prepend   —  A string to prepend to the name
string   $append   —  A string to append to the name

[ Top ]

setValidExtensions   [line 430]

void setValidExtensions( array $exts, [string $mode = 'deny'], [bool $case_sensitive = null])

Function to restrict the valid extensions on file uploads.

Restrictions are applied to the name of the file on the user's disk, not the destination file name used at moveTo().

  • Access: public

Parameters:

array   $exts   —  File extensions to validate
string   $mode   —  The type of validation: 1) 'deny' Will deny only the supplied extensions 2) 'accept' Will accept only the supplied extensions as valid
bool   $case_sensitive   —  whether extension check is case sensitive. When it is case insensitive, the extension is lowercased before compared to the array of valid extensions.

[ Top ]

_chkDirDest   [line 358]

mixed _chkDirDest( string $dir_dest)

Check for a valid destination dir
  • Return: False on no errors or error code on error
  • Access: protected

Parameters:

string   $dir_dest   —  Destination dir

[ Top ]

_evalValidExtensions   [line 464]

bool _evalValidExtensions( )

Evaluates the validity of the extensions set by setValidExtensions.

Checks the validity of the file extension of the original filename the user used for the file on his disk.

  • Return: False on non valid extension, true if they are valid
  • Access: protected

[ Top ]


Documentation generated on Wed, 18 Jan 2017 14:00:02 +0000 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.