为CakePHP 2.x安装Uploader插件 [英] Installing Uploader Plugin for CakePHP 2.x

查看:162
本文介绍了为CakePHP 2.x安装Uploader插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我是新的在这个整个CakePHP的东西,但我正在寻找安装Uploader插件。在下载/将文件放置在正确位置后,我遇到了第一个安装步骤: http:// milesj.me/code/cakephp/uploader 。我看到这是我需要添加到某处的代码:

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!

编辑:我有CakePlugin部分工作。我只是不确定的应用程序:导入行。我不断尝试添加它在我的MediaController类,但它只是引发错误。

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

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

推荐答案

我没有使用这个特定的插件,但我使用了一个类似的(MeioUpload)。

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

CakePlugin :: load('Uploader')进入您的引导配置文件(app / config / bootstrap.php)

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

App :: import和创建可能在您的Media控制器中处理。

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

例如。我的蛋糕应用程序在其PostController中使用 App :: uses('Sanitize','Utility');

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

编辑:

我假设会是这样的。

<?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.

这篇关于为CakePHP 2.x安装Uploader插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆