Question

So I'm new at this whole CakePHP thing, but I'm looking to get the Uploader plugin installed. I'm stuck at the first installation step, after download/placing the files in the correct place: http://milesj.me/code/cakephp/uploader. I see this is the code I need to add somewhere:

// CakePHP 2
CakePlugin::load('Uploader');
App::import('Vendor', 'Uploader.Uploader');
$this->Uploader = new Uploader();

But I don't know where to put it! I'm using the basic "Blog tutorial", but I changed the name from "Posts" to "Media". Where would I put this code to get the plugin included? I'm not sure on the rest of the steps either, so if anyone could help me with that in terms of the default "Blog tutorial" setup, that'd be awesome. Thanks!

EDIT: I have the CakePlugin part working. I'm just unsure about the App:import line. I keep trying to add it inside my MediaController class, but it's just throwing errors. Where would this line go?

EDIT: App:import line is working, now I just need the new Uploader() part

Was it helpful?

Solution

I havn't used this specific plugin, but I have used one similar (MeioUpload).

The CakePlugin::load('Uploader') goes in your bootstrap configuration file (app/config/bootstrap.php)

App::import and the creation are likely to be handled within your "Media" controller.

For example. My Cake App uses App::uses('Sanitize', 'Utility'); in its PostController.

EDIT:

I assume it would be something like this.

<?php
    App::import('Vendor', 'Uploader.Uploader');
    class MediaController extends AppController {
        $this->Uploader = new Uploader();
        /* The rest of the controller */
    }

But I could be wrong. The explanation for that plugin is weird.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top