teepluss/attach

Laravel 4 附件

v1.0 2014-08-15 10:59 UTC

This package is not auto-updated.

Last update: 2024-09-14 13:56:14 UTC


README

Attach 是 Laravel 版本 4 的文件上传器。

安装

要获取最新的主题版本,只需在您的 composer.json 文件中引入它。

"teepluss/attach": "dev-master"

然后您需要运行 composer install 以下载它并更新自动加载器。

一旦 Attach 安装完毕,您需要将服务提供者注册到应用程序中。打开 app/config/app.php 并找到 providers 键。

'providers' => array(

    'Teepluss\Attach\AttachServiceProvider'

)

Attach 还附带了一个外观,它提供了创建集合的静态语法。您可以在 app/config/app.php 文件的 aliases 键中注册外观。

'aliases' => array(

    'Attach' => 'Teepluss\Attach\Facades\Attach'

)

使用 artisan CLI 发布配置。

php artisan config:publish teepluss/attach

用法

基本上传

$attach = Attach::inject(array(
    'subpath' => 'tee'
))
->add(Input::file('userfile'))
->upload();

var_dump($attach->onComplete());

远程上传

$attach = Attach::inject(array(
    'remote' => true
))
->add('http://...../file.png')
->upload();

缩放

$attach = Attach::open('/path/to/image.png')->resize();

// To specific scales from config.

$attach = Attach::open('/path/to/image.png')->resize(array('l', 'm'));

上传和缩放

$attach = Attach::add(Input::file('userfile'))->upload()->resize();

删除

$attach = Attach::open($path)->remove();

您可以在任何时候注入您的配置

$attach = Attach::inject(array(
    ..... YOUR CONFIG .....
))
->upload();

回调

Attach::inject(array(

    'onUpload' => function($result)
    {
        //
    },

    'onComplete' => function($results)
    {
        //
    },

    'onRemove' => function($result)
    {
        //
    }

))
->upload()
->resize();

支持或联系

如果您有任何问题,请联系 teepluss@gmail.com

Support via PayPal