PHP code example of xety / cake3-upload

1. Go to this page and download the library: Download xety/cake3-upload library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xety / cake3-upload example snippets

 php
"ty/cake3-upload": "1.*"
},
 php
Plugin::load('Xety/Cake3Upload');
 php
$this->addBehavior('Xety/Cake3Upload.Upload', [
		'fields' => [
			'avatar' => [
				'path' => 'upload/avatar/:id/:md5'
			]
		]
	]
);
 php
	$this->Form->create($foo, ['type'=>'file']);
	// .. or ..
	$this->Form->create($foo, ['enctype' => 'multipart/form-data']);
 php
<?= $this->Form->input('avatar_file', ['type' => 'file']) 
 php
	protected $_accessible = [
		# ..
        	'avatar_field' => true,
        	# ..
        	];
 php
    $this->addBehavior('Upload', [
    		'fields' => [
    			'avatar' => [
    				'path' => 'upload/avatar/:id/:md5'
    			]
    		],
    		'suffix' => '_anotherName'
    	]
    );

    <?= $this->Form->input('avatar_anotherName', ['type' => 'file']) 
 php
    $this->addBehavior('Upload', [
    		'fields' => [
    			'avatar' => [
    				'path' => 'upload/avatar/:id/:md5',
                    'overwrite' => false
    			]
    		]
    	]
    );
    
 php
    $this->addBehavior('Upload', [
    		'fields' => [
    			'avatar' => [
    				'path' => 'upload/avatar/:id/:md5',
                    'overwrite' => true,
                    'defaultFile' => 'default_avatar.png'
    			]
    		]
    	]
    );
    
 php
    $this->addBehavior('Upload', [
    		'fields' => [
    			'avatar' => [
    				'path' => 'upload/avatar/:id/:md5',
    				'prefix' => '../'
    			]
    		]
    	]
    );