Class Upload
Upload component
Simplifies the file upload and storage for files added to the filesystem
Requires the Input Component
Copyright: Copyright (c) 2010, Phillips Data, Inc.
License: The Blesta License Agreement
Link: Blesta
Located at components/upload/upload.php
Methods summary
public
|
|
public
|
#
setFiles( array $files, boolean $uploaded_files = true )
Sets the array of files to be considered for handling. This class automatically defaults the set of arrays to the global FILES array |
public
|
#
setUploadPath( string $path, mixed $create = false )
Sets the upload path. The upload path will be verified when files are written. If the upload path is invalid file uploads will result in errors |
public
|
#
setMaxFileSize( integer $bytes = 0 )
Sets the maximum file size in bytes. The server may have its own setting for maximum file sizes, so ensure that this value does not exceede the server's allowed maximum size |
public
|
|
public
|
#
writeFile( string $file, boolean $overwrite = true, string $file_name = null, callable $rename_callback = null )
Writes one or more files to the file system. Because of the nature of writing files to the disk, if any file fails execution will continue. Any failed files will be reported by Upload::errors() |
public
|
#
writeFiles( array $files, boolean $overwrite = true, array $file_names = null, callable $rename_callback = null )
Writes multiple files to the file system. Because of the nature of writing files to the disk, if any file fails execution will continue. Any failed files will be reported by Upload::errors() |
private
boolean
|
#
write( array $file, string $key = null, string $index = null, boolean $overwrite = true, string $file_name = null, callable $rename_callback = null )
Writes a file to the file system from the given set files |
public
array
|
|
public
|
#
createUploadPath( string $path, integer $permissions = 0755 )
Recursively creates the upload path if it does not already exists. Also sets permissions to the given set when the directory is created |
public
array
|
|
public
string
|
#
appendCount( string $file_name )
Returns a suggested file name with a number appended at the end so that it is unique in the upload path |
public
string
|
#
md5( mixed $file_name )
Returns a suggested file name that uses an MD5 hash of the existing file name while preserving the file extension. For example my_file.txt becomes 3715ac9af3d0d8cb0970e08494034357.txt, that is md5(my_file.txt) with .txt appended. |
Magic methods summary
Properties summary
private
array
|
$allowed_mime_types |
#
An array of allowed MIME types |
private
integer
|
$max_file_size |
#
The maximum file size allowed, 0 for unlimited |
private
string
|
$upload_path |
#
The full path to the upload directory, where files should be written |
private
array
|
$files |
#
An array of files from the global FILES variable |
private
array
|
$errors |
#
An array of errors to be set |
private
array
|
$data |
#
An array of data about the upload |
private
boolean
|
$uploaded_files |
#
True if the files given have been uploaded, false if they were created instead |