Skip to content

CakePHP3 plugin allowing to easily use the blueimp jQuery-File-Upload

License

Notifications You must be signed in to change notification settings

jorgemarcondes/cakephp3-blueimp-upload

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cakephp3-blueimp-upload

CakePHP3 plugin allowing to easily use the blueimp jQuery-File-Upload

General Features

  • A helper allows to create an upload button with a progess bar
  • A component manage the uploads requests (may be in multiple chunks)
  • Each upload is stored into a datatable with the file infos
  • Once the upload is over, do what you want in your application with the record and the uploaded file

Installation

Adding the plugin

You can easily install this plugin using composer as follows:

...
"repositories": [
    {
        "type": "vcs", 
        "url": "https://github.com/jorgemarcondes/cakephp3-blueimp-upload.git"
    }
],
...
"require": {
    ...
    "jorgemarcondes/cakephp3-blueimp-upload": "*"
    ...
},
...

Enabling the plugin

After adding the plugin remember to load it in your config/bootstrap.php file. The Alaxos plugin must be loaded as well.

Plugin::load('Alaxos', ['bootstrap' => true]);
Plugin::load('CakephpBlueimpUpload');

Using the plugin

Template

echo $this->BlueimpUpload->chunked('picture_upload', [
                                   'upload_url' => Router::url(['controller' => 'Posts', 'action' => 'upload_picture', $post->id])
                                ]);

Check for options in the chunked() method.

Controller

public $components = ['CakephpBlueimpUpload.Uploader'];
public $helpers    = ['CakephpBlueimpUpload.BlueimpUpload'];

public function upload_picture($id = null)
{
    ...
    
    $upload = $this->Uploader->upload($upload_folder, ['accepted_mimetypes' => ['image/jpeg', 'image/tiff', 'image/png']]);

    if($upload !== false)
    {
        if($upload->complete)
        {
           /*
            * The upload is over. 
            * Do what you want with the $upload entity
            */
        }
    }
    
    ...
}

About

CakePHP3 plugin allowing to easily use the blueimp jQuery-File-Upload

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 34.4%
  • JavaScript 30.8%
  • HTML 26.2%
  • Go 3.6%
  • Python 3.1%
  • CSS 1.9%