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

Class: upload

Source Location: /system/classes/upload.class.php

Class Overview


This class will allow you to securely upload one or more files from a form submitted via POST method. Please read documentation as there are a number of security related features that will come in handy for you.


Author(s):

  • Tony Bibbs, tony AT tonybibbs DOT com

Methods



Class Details

[line 41]
This class will allow you to securely upload one or more files from a form submitted via POST method. Please read documentation as there are a number of security related features that will come in handy for you.



Tags:

author:  Tony Bibbs, tony AT tonybibbs DOT com


[ Top ]


Class Methods


constructor __construct [line 174]

upload __construct( )

Constructor



Tags:

access:  public


[ Top ]

method areErrors [line 1097]

boolean areErrors( )

Returns if any errors have been encountered thus far



Tags:

return:  returns true if there were errors otherwise false


[ Top ]

method checkMimeType [line 1134]

boolean checkMimeType( )

Checks to see that mime type for current file is allowed for upload



Tags:

return:  true if current file's mime type is allowed otherwise false


[ Top ]

method getAllowedMimeTypes [line 1123]

array getAllowedMimeTypes( )

Gets allowed mime types for this instance



Tags:

return:  Returns array of allowed mime types


[ Top ]

method getPath [line 1198]

string getPath( )

Returns directory to upload to



Tags:

return:  returns path to file upload directory


[ Top ]

method keepOriginalImage [line 886]

boolean keepOriginalImage( boolean $keepit)

Allows you to keep the original (unscaled) image.



Tags:

return:  true if we set values OK, otherwise false


Parameters:

boolean   $keepit   true = keep original, false = don't

[ Top ]

method limitByIP [line 922]

boolean limitByIP( [array $validIPS = array('127.0.0.1')])

Extra security option that forces all attempts to upload a file to be done so from a set of VERY specific IP's. This is only good for those who are paranoid



Tags:

return:  returns true if we successfully limited the IP's, otherwise false


Parameters:

array   $validIPS   Array of valid IP addresses to allow file uploads from

[ Top ]

method loggingEnabled [line 995]

boolean loggingEnabled( )

Returns whether or not logging is enabled



Tags:

return:  returns true if logging is enabled otherwise false


[ Top ]

method numFiles [line 1251]

int numFiles( )

Returns how many actual files were sent for upload. NOTE: this will ignore HTML file fields that were left blank.



Tags:

return:  returns number of files were sent to be uploaded


[ Top ]

method printDebugMsgs [line 1079]

void printDebugMsgs( )

This function will print any debug messages out.



[ Top ]

method printErrors [line 1041]

string printErrors( [boolean $verbose = true])

This function will print any errors out. This is useful in debugging



Tags:

return:  if $verbose is false it returns all errors otherwise just an empty string


Parameters:

boolean   $verbose   whether or not to print immediately or return only a string

[ Top ]

method printWarnings [line 1063]

void printWarnings( )

This function will print any warnings out. This is useful in debugging



[ Top ]

method setAllowedMimeTypes [line 1112]

void setAllowedMimeTypes( [array $mimeTypes = array()])

Sets allowed mime types for this instance



Parameters:

array   $mimeTypes   allowedMimeTypes Array of allowed mime types

[ Top ]

method setAutomaticResize [line 825]

void setAutomaticResize( boolean $switch)

Sets mode to automatically resize images that are either too wide or too tall



Parameters:

boolean   $switch   True to turn on, false to turn off

[ Top ]

method setContinueOnError [line 943]

void setContinueOnError( boolean $switch)

Allows you to specify whether or not to continue processing other files when an error occurs or exit immediately. Default is to exit immediately

NOTE: this only affects the actual file upload process.




Parameters:

boolean   $switch   true or false

[ Top ]

method setDebug [line 1007]

void setDebug( boolean $switch)

Will force the debug messages in this class to be printed



Parameters:

boolean   $switch   flag, true or false

[ Top ]

method setFileNames [line 1213]

void setFileNames( [string|array $fileNames = 'geeklog_uploadedfile'])

Sets file name(s) for files

This function will set the name of any files uploaded. If the number of file names sent doesn't match the number of uploaded files a warning will be generated but processing will continue




Parameters:

string|array   $fileNames   A string or string array of file names

[ Top ]

method setGDLib [line 812]

boolean setGDLib( )

Configure upload to use GD library



Tags:

return:  True if set, false otherwise


[ Top ]

method setIgnoreMimeCheck [line 1024]

void setIgnoreMimeCheck( boolean $switch)

If enabled will ignore the MIME checks on file uploads



Parameters:

boolean   $switch   flag, true or false

[ Top ]

method setJpegQuality [line 903]

boolean setJpegQuality( int $quality)

Set JPEG quality

NOTE: The 'quality' is an arbitrary value used by the IJG library. It is not a percent value! The default (and a good value) is 75.




Tags:

return:  true if we set values OK, otherwise false


Parameters:

int   $quality   JPEG quality (0-100)

[ Top ]

method setLogFile [line 959]

boolean setLogFile( [string $logFile = ''])

Sets log file



Tags:

return:  returns true if we set the log file, otherwise false


Parameters:

string   $logFile   fully qualified path to log files

[ Top ]

method setLogging [line 977]

void setLogging( boolean $switch)

Enables/disables logging of errors and warnings



Parameters:

boolean   $switch   flag, true or false

[ Top ]

method setMaxDimensions [line 854]

boolean setMaxDimensions( int $width_pixels, int $height_pixels)

Allows you to override default max. image dimensions



Tags:

return:  true if we set values OK, otherwise false


Parameters:

int   $width_pixels   Max. width allowed
int   $height_pixels   Max. height allowed

[ Top ]

method setMaxFileSize [line 837]

boolean setMaxFileSize( int $size_in_bytes)

Allows you to override default max file size



Tags:

return:  true if we set it OK, otherwise false


Parameters:

int   $size_in_bytes   Max. size for uploaded files

[ Top ]

method setMaxFileUploads [line 873]

boolean setMaxFileUploads( int $maxfiles)

Sets the max number of files that can be uploaded per form



Tags:

return:  True if set, false otherwise


Parameters:

int   $maxfiles   Maximum number of files to allow. Default is 5

[ Top ]

method setMogrifyPath [line 785]

boolean setMogrifyPath( string $path_to_mogrify)

Sets the path to where the mogrify ImageMagick function is



Tags:

return:  True if set, false otherwise


Parameters:

string   $path_to_mogrify   Absolute path to mogrify

[ Top ]

method setNetPBM [line 799]

boolean setNetPBM( string $path_to_netpbm)

Sets the path to where the netpbm utilities are



Tags:

return:  True if set, false otherwise


Parameters:

string   $path_to_netpbm   Absolute path to netpbm dir

[ Top ]

method setPath [line 1175]

boolean setPath( string $uploadDir)

Sets file upload path



Tags:

return:  returns true if we successfully set path otherwise false


Parameters:

string   $uploadDir   Directory on server to store uploaded files

[ Top ]

method setPerms [line 1234]

void setPerms( string|array $perms)

Changes permissions for uploaded files. If only one set of perms is

sent then they are applied to all uploaded files. If more then one set of perms is sent (i.e. $perms is an array) then permissions are applied one by one. Any files not having an associated permissions will be left alone. NOTE: this is meant to be called BEFORE you do the upload and ideally is called right after setFileNames()




Parameters:

string|array   $perms   A string or string array of file permissions

[ Top ]

method uploadFiles [line 1278]

boolean uploadFiles( )

Uploads any posted files.



Tags:

return:  returns true if no errors were encountered otherwise false


[ Top ]


Documentation generated on Sun, 02 Oct 2016 07:56:36 +0000 by phpDocumentor 1.4.3