Download the PHP package xety/cake3-upload without Composer
On this page you can find all versions of the php package xety/cake3-upload. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package cake3-upload
Cake3 Upload
A Cake3 plugin to upload files.
Requirements
- CakePHP 3.X
Installation
Run : composer require xety/cake3-upload:1.*
Or add it in your composer.json
:
Usage
In your config/bootstrap.php
add :
In your model initialize()
:
Set your form to accept files
To create an input to upload a file, just use the this rule : fieldName_file. Example :
If specified in your Entity, add the suffixed field (e.g. avatar_file
) to the $_accessible
array:
Identifiers
- :id Id of the Entity (It can be the user Id if you are using this for the users table for example)
- :md5 A random and unique identifier with 32 characters. i.e : bbebb3c3c5e76a46c3dca92c9395ee65
- :y Based on the current year. i.e : 2014
- :m Based on the current month. i.e : 09
Configuration
-
suffix
Default :
_file
You can change the suffix _file to your own suffix :
-
overwrite
Default :
true
This option allow you to define if the behavior must delete and/or overwrite the old file for the field. If the option is false, the file will be not uploaded if the old file name has the same name as the new name file. It can be useful if you want your users to upload only one image.
-
defaultFile
Default :
false
This option allow you to defined a default file for the field. It can be useful if you have defined a default avatar for all your new user and you don't want to delete it (i.e : In your database as defaut value for avatar you have set : "../img/default_avatar.png"). Will work only if the overwrite is defined to true.
-
prefix
Default :
false
This option allow you to defined a prefix for your upload path. Useful if you don't want to use the img/ directory for your upload.
Example :
If you use a custom directory at the root of the webroot directory and you use the
HtmlHelper
to display your image, you can set a prefix like this :