Skip to content

Latest commit

 

History

History
843 lines (404 loc) · 19 KB

class.Upload.md

File metadata and controls

843 lines (404 loc) · 19 KB

Class Upload

This class provide all file upload functionalities

Contents

Properties

Methods

Properties

$_value

public mixed $_value = null

$dirPath

public mixed $dirPath = ""

$errCode

public mixed $errCode = ""

$errorCodes

public mixed $errorCodes = array(0 => 'the file uploaded with success', 1 => 'The uploaded file exceeds the upload_max_filesize directive in php.ini', 2 => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form', 3 => 'The uploaded file was only partially uploaded', 4 => 'No file was uploaded.', 6 => 'Missing a temporary folder', 7 => 'Failed to write file to disk', 8 => 'File upload stopped by extension', 999 => 'No error code avaiable')

$errors

public mixed $errors = array()

$fileBaseName

public mixed $fileBaseName = ""

$fileExtension

public mixed $fileExtension = ""

$fileName

public mixed $fileName = ""

$filePath

public mixed $filePath = ""

$fileSize

public mixed $fileSize

$fileType

public mixed $fileType = ""

$imgHandler

public mixed $imgHandler = null

$img_new_x

public mixed $img_new_x

$img_new_y

public mixed $img_new_y

$img_x

public mixed $img_x

$img_y

public mixed $img_y

$invalidFileExt

public mixed $invalidFileExt = array()

$originalFileName

public mixed $originalFileName = ""

$safeMode

public mixed $safeMode

$uploadFileMode

public mixed $uploadFileMode = 493

$validImageExts

public mixed $validImageExts = array("gif", "jpg", "png")

Methods

Upload

mixed Upload::Upload()

_get_image_details

void Upload::_get_image_details($image)

Arguments

  • $image mixed

_imageSave

boolean Upload::_imageSave(resource $newImageHandler, string $fileName, integer $quality)

save the thumbnail file and destroy the opened image

Arguments

  • $newImageHandler resource
  • $fileName string
  • $quality integer

_resize

\unknown Upload::_resize(string $fileName, integer $new_x, integer $new_y)

resize the image and return the thumbnail image details array("width"=>, "height"=>, "name")

Arguments

  • $fileName string
  • $new_x integer - the thumbnail width
  • $new_y integer - the thumbnail height

deleteFileAndThumbs

mixed Upload::deleteFileAndThumbs(string $dirPath, string $originalImageName, string $arrayThumbnailSuffix)

delete the uploaded image file & associated thumnails

Arguments

  • $dirPath string
  • $originalImageName string
  • $arrayThumbnailSuffix string

deleteUploadedFile

mixed Upload::deleteUploadedFile()

get the uploaded file

displayError

mixed Upload::displayError()

finish

mixed Upload::finish()

destroy the tmp file

getDirPath

\unknown Upload::getDirPath()

return the directory path witch the file uploaded to

getErrorCodeMsg

mixed Upload::getErrorCodeMsg()

getFileBaseName

mixed Upload::getFileBaseName()

getFileExt

mixed Upload::getFileExt()

get a file extension

getFileName

mixed Upload::getFileName()

getFilePath

mixed Upload::getFilePath()

get the path which the file uploaded to

getFileSize

string Upload::getFileSize()

get uploaded file size

getFileType

string Upload::getFileType()

get file type

getImageHeight

integer Upload::getImageHeight()

get image height

getImageWidth

integer Upload::getImageWidth()

get image width

getThumbInfo

array Upload::getThumbInfo(string $originalImageName, integer $originaleImageWidth, integer $originalImageHeight, string $thumbnailSuffix, integer $thumbnailWidth, integer $thumbnailHeight)

caculate the thumbnail details from the original image file

Arguments

  • $originalImageName string
  • $originaleImageWidth integer
  • $originalImageHeight integer
  • $thumbnailSuffix string
  • $thumbnailWidth integer
  • $thumbnailHeight integer

isFileUploaded

mixed Upload::isFileUploaded($indexInPost)

Arguments

  • $indexInPost mixed

isImage

mixed Upload::isImage(mixed $invalidImageExts, boolean $delete)

check if the uploaded is permitted to upload

Arguments

  • $invalidImageExts mixed - invalid image extension
  • $delete boolean - force to delete the uploaded file

isPermittedFileExt

boolean Upload::isPermittedFileExt(array $validFileExt)

check if the uploaded file extension is allowed against the validFile Extension or against the invalid extension list when the list of valid file extension is not set

Arguments

  • $validFileExt array

isSizeTooBig

mixed Upload::isSizeTooBig(integer $maxSize)

check if the uploaded file size is too big

Arguments

  • $maxSize integer

moveUploadedFile

\unknown Upload::moveUploadedFile(string $dest, string $fileBaseName, \unknown_type $overwrite)

move the uploaded file to a specific location

Arguments

  • $dest string - the path to the directory which the uploaded file will be moved to
  • $fileBaseName string - the base name which the uploaded file will be renamed to
  • $overwrite unknown_type

resize

mixed Upload::resize($filePath, string $thumb_suffix, mixed $new_x, mixed $new_y)

Resize the Image in the X and/or Y direction If either is 0 it will be scaled proportionally

Arguments

  • $filePath mixed
  • $thumb_suffix string
  • $new_x mixed
  • $new_y mixed

setInvalidFileExt

mixed Upload::setInvalidFileExt(array $invalidFileExt)

set the invali file extensions

Arguments

  • $invalidFileExt array