jaimevalasek/jv-upload

适用于 ZF2 的通用上传文件模块。

dev-master 2013-10-03 18:08 UTC

This package is not auto-updated.

Last update: 2024-09-24 04:39:07 UTC


README

创建者:Jaime Marcelo Valasek

使用此模块上传文件。

未来的视频课程可以在网站或 YouTube 频道 http://www.zf2.com.br/tutoriais - http://www.youtube.com/zf2tutoriais 上开发并发布

安装

将此模块下载到您的 vendor 文件夹中。

完成上述步骤后,打开文件 config/application.config.php。并添加名为 JVUpload 的模块。

依赖模块

  • 要使用此模块,您还必须安装以下模块

JVConfig - https://github.com/jaimevalasek/JVConfig JVEasyPhpThumbnail - https://github.com/jaimevalasek/JVEasyPhpThumbnail JVMimeTypes - https://github.com/jaimevalasek/JVMimeTypes

使用 composer

  1. 在您的 composer.json 中添加此项目和 JVEasyPhpThumbnail + JVMimeTypes + JVConfig
"require": {
    "jaimevalasek/jv-upload": "dev-master"
}
  1. 现在通过运行以下命令让 composer 下载 JVUpload

php php composer.phar update

安装后

1. 在您的 application.config.php 中启用它。

<?php
return array(
    'modules' => array(
        // ...
        'JVConfig',
        'JVEasyPhpThumbnail',
        'JVMimeTypes',
        'JVUpload',
    ),
    // ...
);
  1. 配置数组配置模块 JVConfig 或在您的主模块中
<?php
return array(
	// ...
	'jv-upload' => array(
	    'types' => array(
	        'image', 'audio', 'video', 'app', 'thumb', 'text', 'file', 'custom'
	    ),
	),
	// ...
);

使用 JVUpload

基本图片示例

$upload = new \JVUpload\Service\Upload($this->getServiceLocator()->get('servicemanager'));
$upload->setType('image')
    ->setThumb(array('destination' => '/conteudos/thumbs', 'width' => 200, 'height' => 250, 'cropimage' => array(2,0,40,40,50,50)))
    ->setExtValidation('ext-image-min')
    ->setSizeValidation(array('18', '200')) // validation of the file size in KB array (min max).
    ->setDestination('/conteudos/imagens')
    ->prepare()->execute();