Class FileUploader

Description

FileUploader is a class that allows for easy implementation for uploading multiple image or audio files at once.

This class may also upload a single image from a URL

  • author: Michael Dahlke

Located in /classes/FileUploader.class.php (line 10)


	
			
Direct descendents
Class Description
 class AudioUploader FileUploader is a class that allows for easy implementation for uploading multiple image or audio files at once.
 class ImageUploader FileUploader is a class that allows for easy implementation for uploading multiple image or audio files at once.
 class UploadAudio FileUploader is a class that allows for easy implementation for uploading multiple image or audio files at once.
Variable Summary
Method Summary
 void checkDirectoryStatus ( $folder)
 bool checkIfFileExists (string $filename)
 int countItemsInDirectory (string $folder)
 void createDirectory (string $folder)
 void detectFileType (string $file)
 boolean fileIsNotEmpty (int $fileSize)
 boolean fileSmallEnoughForUpload (int $fileSize)
 void getFileType ()
 void inParentDirectory ([ $input = true])
 boolean isAcceptableFileType (string $fileType)
 string returnUploadErrorCodeAtIndex (int $index)
 string returnUploadErrorFileNameAtIndex (int $index)
 string returnUploadErrorLineNumberAtIndex (int $index)
 string returnUploadErrorMessageAtIndex (int $index)
 void setErrorLogFilename ( $input)
 void setFileType ( $input)
 void setFileTypeForUpload ( $input)
 void setMaxUploadSize (int $input)
 void setPrependToFileName (string $input)
 boolean validateFile ( $fileName, string $fileSize, string $fileType)
Variables
mixed $allowedAudioTypes = array(
'audio/mpeg','audio/x-mpeg','audio/mp3',
'audio/x-mp3','audio/mpeg3','audio/x-mpeg3',
'audio/mpg','audio/x-mpg','audio/x-mpegaudio',
'audio/wav','audio/x-wav','audio/ogg',
'audio/mp4','audio/mid','audio/x-aiff',
'audio/rmi'
)
(line 33)
  • access: protected
mixed $allowedImageTypes = array(
'image/png','image/jpeg',
'image/jpg','image/pjpeg',
'image/gif'
)
(line 41)
  • access: protected
mixed $allUploadErrorCodes = array() (line 28)
  • access: protected

Redefined in descendants as:
mixed $allUploadErrorMessages = array() (line 27)
  • access: protected

Redefined in descendants as:
mixed $allUploadErrorsFileName = array() (line 30)
  • access: protected
mixed $allUploadErrorsLineNumber = array() (line 29)
  • access: protected

Redefined in descendants as:
mixed $errorLogFileName = 'FileUploaderErrorLog.txt' (line 18)
  • access: protected

Redefined in descendants as:
mixed $fileType = array() (line 19)
  • access: protected
mixed $fileTypeForUpload (line 21)
  • access: protected

Redefined in descendants as:
mixed $maxUploadSize = 5242880 (line 17)
  • access: protected

Redefined in descendants as:
mixed $numberOfAllowedFilesToUpload = 1 (line 16)
  • access: protected
mixed $numberOfErrors = 0 (line 24)
  • access: protected

Redefined in descendants as:
mixed $numberOfFilesPerDirectory = 100 (line 15)
  • access: protected
mixed $numberOfSuccessfulUploads = 0 (line 23)
  • access: protected

Redefined in descendants as:
mixed $originalFilePath = 'upload/' (line 13)
  • access: protected
mixed $prependToFileName = "" (line 14)
  • access: protected
mixed $userReadableUploadErrorCodes = array() (line 26)
  • access: protected

Redefined in descendants as:
mixed $userReadableUploadErrorMessages = array() (line 25)
  • access: protected

Redefined in descendants as:
Methods
checkDirectoryStatus (line 309)
  • access: protected
void checkDirectoryStatus ( $folder)
  • $folder

Redefined in descendants as:
checkIfFileExists (line 324)

Check if the uploading file already exists

  • return: return true if file does not exist, false if it does
  • access: public
bool checkIfFileExists (string $filename)
  • string $filename: full filename of the the file to be checked

Redefined in descendants as:
countItemsInDirectory (line 271)

count items in a folder

  • return: number of items in the directory
  • access: protected
int countItemsInDirectory (string $folder)
  • string $folder: path of the folder you want the item count of

Redefined in descendants as:
createDirectory (line 284)
  • access: protected
void createDirectory (string $folder)
  • string $folder: folder name to be created

Redefined in descendants as:
detectFileType (line 123)

Detect the file type of an uploading file NOTE: this does NOT validate this just says what type of file it is

  • access: public
void detectFileType (string $file)
  • string $file:

    the file to be checked

    $return void

fileIsNotEmpty (line 194)

Check that there is indeed an image present throw exception

  • return: returns true/false
  • access: protected
boolean fileIsNotEmpty (int $fileSize)
  • int $fileSize: filesize of an image
fileSmallEnoughForUpload (line 179)

Check to make sure the file isn't over the maximum allowed filesize Max Allowed Filesize: 5MB throw exception

  • return: returns true/false
  • access: protected
boolean fileSmallEnoughForUpload (int $fileSize)
  • int $fileSize: filesize of an image
getErrorLogFilename (line 94)
  • access: public
void getErrorLogFilename ()

Redefined in descendants as:
getFileType (line 101)
  • access: public
void getFileType ()

Redefined in descendants as:
getFileTypeForUpload (line 108)
  • access: protected
void getFileTypeForUpload ()
getMaxUploadSize (line 87)
  • access: public
void getMaxUploadSize ()

Redefined in descendants as:
getNumberOfAllowedFilesToUpload (line 69)
  • access: public
void getNumberOfAllowedFilesToUpload ()
getNumberOfErrorsDuringUpload (line 356)
  • return: the number of errors that occured during upload
  • access: public
int getNumberOfErrorsDuringUpload ()

Redefined in descendants as:
getNumberOfFilesPerDirectory (line 76)
  • access: public
void getNumberOfFilesPerDirectory ()

Redefined in descendants as:
getNumberOfSuccessfulUploads (line 83)
  • access: public
void getNumberOfSuccessfulUploads ()

Redefined in descendants as:
getPrependToFileName (line 55)
  • access: public
void getPrependToFileName ()
inParentDirectory (line 51)
  • access: public
void inParentDirectory ([ $input = true])
  • $input
isAcceptableFileType (line 146)

Check to make sure the file is an acceptable file for upload throw exception

  • return: returns true/false
  • access: protected
  • example: example not found
boolean isAcceptableFileType (string $fileType)
  • string $fileType: The file type of an image
returnAllUploadErrorCodes (line 382)
  • return: return all error codes
  • access: public
string returnAllUploadErrorCodes ()

Redefined in descendants as:
returnAllUploadErrorMessages (line 376)
  • return: return all error messages
  • access: public
string returnAllUploadErrorMessages ()

Redefined in descendants as:
returnAllUploadErrorsFileName (line 394)
  • return: return all error filenames
  • access: public
string returnAllUploadErrorsFileName ()
returnAllUploadErrorsLineNumber (line 388)
  • return: return all error line numbers
  • access: public
string returnAllUploadErrorsLineNumber ()

Redefined in descendants as:
returnFormattedErrors (line 434)
  • return: returns error messages in a nice format
  • access: public
string returnFormattedErrors ()

Redefined in descendants as:
returnUploadErrorCodeAtIndex (line 411)
  • return: an error code at a specific index
  • access: public
string returnUploadErrorCodeAtIndex (int $index)
  • int $index: index of desired error code

Redefined in descendants as:
returnUploadErrorFileNameAtIndex (line 427)
  • return: a filename at a specific index
  • access: public
string returnUploadErrorFileNameAtIndex (int $index)
  • int $index: index of desired line number
returnUploadErrorLineNumberAtIndex (line 419)
  • return: a line number at a specific index
  • access: public
string returnUploadErrorLineNumberAtIndex (int $index)
  • int $index: index of desired line number
returnUploadErrorMessageAtIndex (line 403)
  • return: an error message at a specific index
  • access: public
string returnUploadErrorMessageAtIndex (int $index)
  • int $index: index of desired error message

Redefined in descendants as:
returnUserReadableUploadErrorCodes (line 369)
  • return: return error codes that are safe or relevant for a user
  • access: public
string returnUserReadableUploadErrorCodes ()

Redefined in descendants as:
returnUserReadableUploadErrorMessages (line 362)
  • return: error messages that are safe or relevant for a user
  • access: public
string returnUserReadableUploadErrorMessages ()

Redefined in descendants as:
setErrorLogFilename (line 97)
  • access: public
void setErrorLogFilename ( $input)
  • $input

Redefined in descendants as:
setFileType (line 104)
  • access: public
void setFileType ( $input)
  • $input

Redefined in descendants as:
setFileTypeForUpload (line 111)
  • access: protected
void setFileTypeForUpload ( $input)
  • $input
setMaxUploadSize (line 90)
  • access: public
void setMaxUploadSize (int $input)
  • int $input

Redefined in descendants as:
setNumberOfAllowedFilesToUpload (line 72)
  • access: public
void setNumberOfAllowedFilesToUpload ( $input)
  • $input
setNumberOfFilesPerDirectory (line 79)
  • access: public
void setNumberOfFilesPerDirectory ( $input)
  • $input

Redefined in descendants as:
setPrependToFileName (line 62)
  • access: public
void setPrependToFileName (string $input)
  • string $input: whatever you would like prepended to the filename (max: 20 characters)
validateFile (line 216)

Run the validation tests for the image

ex. check if it's indeed an image check if under maximum size Perhaps down the road have a minium size (it is currently at zero)

  • return: returns true if all validations pass or false if any fail
  • access: protected
boolean validateFile ( $fileName, string $fileSize, string $fileType)
  • string $fileSize: file size of the image to be checked
  • string $fileType: file type of the image to be checked
  • $fileName
writeAllErrorsToLog (line 451)

Write all upload errors to an error log

  • access: protected
void writeAllErrorsToLog ()

Redefined in descendants as:

Documentation generated on Wed, 28 Aug 2013 22:54:20 -0500 by phpDocumentor 1.4.4