Overview

Packages

  • blesta
    • app
      • controllers
      • models
    • components
      • auth
        • ldap
        • motp
        • oath
      • delivery
        • interfax
        • postal
          • methods
      • download
      • email
      • events
      • exchange
        • rates
          • currency
            • layer
          • fixer
          • open
            • exchange
              • rates
          • x
            • rates
      • gateway
        • payments
      • gateways
      • invoice
        • delivery
        • templates
          • perforated
            • invoice
          • quickbooks
            • invoice
          • templates
            • default
      • modules
      • net
        • amazon
          • s3
        • http
        • net
          • geo
            • ip
      • plugins
      • reports
        • aging
          • invoices
        • client
          • data
            • portability
        • custom
          • report
        • invoice
          • creation
        • package
          • revenue
        • tax
          • liability
        • transactions
          • applied
          • received
      • security
      • session
        • cart
      • settingscollection
      • upgrades
        • tasks
      • upload
      • vcard
    • core
      • Automation
        • Tasks
          • Common
          • Task
        • Type
          • Common
          • Cron
      • Pricing
        • ItemComparator
        • MetaItem
        • Modifier
          • Type
            • Description
              • Type
                • Discount
                • Option
                • Service
                • Tax
            • Discount
            • Price
            • Proration
        • Presenter
          • Build
            • Invoice
            • InvoiceData
            • Options
            • Service
            • ServiceChange
            • ServiceData
          • Collection
          • Format
            • Fields
            • Type
              • Discount
              • Item
              • Option
              • Options
              • Package
              • Pricing
              • Service
              • Tax
          • Items
            • Invoice
            • Service
          • Type
      • ServiceProviders
      • Util
        • Captcha
          • Captchas
          • Common
        • Common
          • Traits
        • Events
          • Common
          • Handlers
          • Observers
        • Filters
          • Common
        • GeoIp
        • Input
          • Fields
            • Common
        • Tax
        • Widgets
    • helpers
      • currency
        • format
      • data
        • structure
          • array
          • string
      • text
        • parser
      • widget
        • client
  • minPHP
    • helpers
      • color
      • data
        • structure
  • None
  • PHP

Classes

  • Upload
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated

Class Upload

Upload component

Simplifies the file upload and storage for files added to the filesystem

Requires the Input Component

Package: blesta\components\upload
Copyright: Copyright (c) 2010, Phillips Data, Inc.
License: The Blesta License Agreement
Link: Blesta
Located at components/upload/upload.php
Methods summary
public
# __construct( )

Initialize the Upload

Initialize the Upload

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

Sets the array of files to be considered for handling. This class automatically defaults the set of arrays to the global FILES array

Parameters

$files

An array of files from the global FILES array to set. The format of this array must match that the global FILES array exactly

$uploaded_files
If true the file was uploaded, false if the file was created and not uploaded
public
# setUploadPath( string $path, boolean $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

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

Parameters

$path
The server path to where files are to be written
$create
Unused argument (optional)
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

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

Parameters

$bytes
The maximum file size in bytes. Set to 0 to use no maximum file size.
public
# setAllowedMimeTypes( array $types = null )

Sets the allowed MIME types

Sets the allowed MIME types

Parameters

$types
An array of MIME types to allow, set to null to allow all MIME types
public
# writeFile( string $file, boolean $overwrite = true, string $file_name = null, callable $rename_callback = null, integer $permissions = 0644 )

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()

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()

Parameters

$file
A field name to search the global file variable for
$overwrite
Whether or not to overwrite the file if it already exists
$file_name

The name of the file to use instead of the uploaded file's name, null to use uploaded file's name

$rename_callback
A callback to execute used to rename the file
$permissions
The permission value in octets, null to default to user permissions
public
# writeFiles( array $files, boolean $overwrite = true, array $file_names = null, callable $rename_callback = null, integer $permissions = 0644 )

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()

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()

Parameters

$files
An array of file field names to search the global file variable for
$overwrite
Whether or not to overwrite the file if it already exists
$file_names

The names of the files to use instead of the uploaded file's name, null to use uploaded file's name

$rename_callback
A callback to execute used to rename the file
$permissions
The permission value in octets, null to default to user permissions
public array
# getUploadData( )

Fetches the upload data

Fetches the upload data

Returns

array

An array of upload data for each of the uploaded files including:

  • orig_name The original name of the uploaded file
  • file_name The new file name
  • file_path The path where the file was written
  • full_path The full path to the file that was written
  • file_size The size of the file that was written (in bytes)
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

Recursively creates the upload path if it does not already exists. Also sets permissions to the given set when the directory is created

Parameters

$path
The directory path to create
$permissions
The permission value in octets
public array
# errors( )

Returns all errors set

Returns all errors set

Returns

array
An array of errors set in Input
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

Returns a suggested file name with a number appended at the end so that it is unique in the upload path

Parameters

$file_name
The name of the file to append a count to

Returns

string
The suggested file name
public string
# md5( $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.

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.

Returns

string
$file_name The suggested file name
Blesta API documentation generated by ApiGen