yf_form2_file_handler class

Fileplugins/form2/classes/form2/yf_form2_file_handler.class.php
Use_class('form2_file_handler', 'classes/form2/')
Not loaded by the docs: it runs code outside its class (require_php_lib on line 3). Read the source instead.

<?php

require_php_lib('jquery-file-upload');
class yf_form2_file_handler extends UploadHandler
{
    public function process($options = null, $initialize = true, $error_messages = null)
    {
        $this->options = [
            'upload_dir' => INCLUDE_PATH . 'uploads/' . ($_GET['object'] ?? null) . '/',
            'upload_url' => WEB_PATH . 'uploads/' . ($_GET['object'] ?? null) . '/',
            'mkdir_mode' => 0755,
            'param_name' => 'files',
            // Set the following option to 'POST', if your server does not support
            // DELETE requests. This is a parameter sent to the client:
            'access_control_allow_origin' => '*',
            'access_control_allow_credentials' => false,
            'access_control_allow_methods' => [
                'HEAD',
                'GET',
                'POST',
            ],
            'access_control_allow_headers' => [
                'Content-Type',
                'Content-Range',
                'Content-Disposition',
            ],
            // Defines which files can be displayed inline when downloaded:
            'inline_file_types' => '/\.(gif|jpe?g|png)$/i',
            // Defines which files (based on their names) are accepted for upload:
            'accept_file_types' => '/.+$/i',
            // The php.ini settings upload_max_filesize and post_max_size
            // take precedence over the following max_file_size setting:
            'max_file_size' => null,
            'min_file_size' => 1,

            // The maximum number of files for the upload directory:
            'max_number_of_files' => null,


            // Defines which files are handled as image files:
            'image_file_types' => '/\.(gif|jpe?g|png)$/i',
            // Image resolution restrictions:
            'max_width' => null,
            'max_height' => null,
            'min_width' => 1,
            'min_height' => 1,
            // Set the following option to false to enable resumable uploads:
            'discard_aborted_uploads' => true,
            // Set to 0 to use the GD library to scale and orient images,
            // set to 1 to use imagick (if installed, falls back to GD),
            // set to 2 to use the ImageMagick convert binary directly:
            'image_library' => 1,
            // Command or path for to the ImageMagick convert binary:
            'convert_bin' => 'convert',
            // Command or path for to the ImageMagick identify binary:
            'identify_bin' => 'identify',

            'versions' => [
            ],
            'image_versions' => [
                // The empty image version key defines options for the original image:
                '' => [
                    // Automatically rotate images based on EXIF meta data:
                    'auto_orient' => true,
                ],
                // Uncomment the following to create medium sized images:
                /*
                'medium' => array(
                    'max_width' => 800,
                    'max_height' => 600
                ),
                */
                /*
                'thumbnail' => array(
                    //'upload_dir' => dirname($this->get_server_var('SCRIPT_FILENAME')).'/thumb/',
                    //'upload_url' => $this->get_full_url().'/thumb/',
                    //'crop' => true,
                    'max_width' => 80,
                    'max_height' => 80
                )
                */
            ],
        ];
        if ($options) {
            $this->options = $options + $this->options;
        }
        if ($error_messages) {
            $this->error_messages = $error_messages + $this->error_messages;
        }
        if ($initialize) {
            $this->initialize();
        }
    }
}