kitpages / file-bundle
FileBundle 管理Kitpages CMS Bundle的文件上传和处理
Requires
- php: >=5.3.2
- doctrine/doctrine-bundle: ~1.1
- doctrine/orm: ~2.2
- imagine/imagine: ~0.4.1
- kitpages/file-system-bundle: ~3.1
- kitpages/util-bundle: ~3.0
- symfony/framework-bundle: ~2.1
- symfony/monolog-bundle: ~2.1
Requires (Dev)
- beberlei/doctrineextensions: dev-master
- doctrine/doctrine-fixtures-bundle: *
- liip/functional-test-bundle: dev-master
- patchwork/dumper: ~1.2
- phpunit/dbunit: ~1.3.1
- phpunit/phpunit: ~3.7
- symfony/browser-kit: ~2.1
- symfony/class-loader: ~2.1
- symfony/finder: ~2.1
- symfony/yaml: ~2.1
This package is auto-updated.
Last update: 2024-09-04 19:07:48 UTC
README
这是一个symfony的ajax上传系统。
作者: Philippe Le Van (@plv)
安装
嗯...和平时一样...
将代码放入 vendors/Kitpages/FileBundle
在 app/autoload.php 中添加 vendors/
在 app/appKernel.php 中添加新的Bundle
您需要在数据库中创建一个表:运行命令:php app/console doctrine:schema:update
在表单中添加文件上传字段
在表单类中 $builder->add( 'fileId', 'hidden', array( "label" => "File" ) );
在文件 Twig 中
<script type="text/javascript" src="{{ asset ("bundles/kitpagesfile/uploadify/jquery.uploadify.min.js") }}"></script>{% include 'KitpagesFileBundle:Upload:pluginJs.html.twig' ignore missing %}
<form class="standard-form" {{ form_enctype(form) }} method="POST">
<div id="form">
{{ form_row(
form.title
) }}
<div>
<label>Image</label>
{{ form_widget(form.file) }}
{% render 'KitpagesFileBundle:Upload:widget' with {'fieldId': 'form_fileId', 'itemClass': 'AppSiteBundle:Document', 'itemId': form.vars.value.id, parameterList:{'multi': false, 'publishParent': false} } %}
</div>
{{ form_widget(form) }}
</div>
<input type="submit" value="Save"/>
</form>
注意 fieldId = 表单中由 "{{ form_widget(form.fileId) }}" 生成的输入的属性 ID
如果存在,更新数据库
更新版本1.2.0的现有数据库
安装 ImagineBundle 和 kitpagesFileSystemBundle
步骤1:将以下条目添加到项目根目录的文件中的 deps
[Imagine] git=http://github.com/avalanche123/Imagine.git target=imagine
[KitpagesFileSystemBundle] git=http://github.com/kitpages/KitpagesFileSystemBundle.git target=Kitpages/FileSystemBundle
步骤2:配置自动加载器
将以下条目添加到自动加载器中
registerNamespaces(array( // ... 'Imagine' => __DIR__.'/../vendor/imagine/lib', )); 步骤3: AppKernel.php 将以下条目添加到自动加载器中:$bundles = array( ... new Kitpages\FileSystemBundle\KitpagesFileSystemBundle(), ); 步骤4: 配置示例 ===================== kitpages_file: tmp_dir: %kernel.root_dir%/data/tmp type_list: image: resize: form: 'kit_file.image.resize.form' form_twig: 'KitpagesFileBundle:ActionOnFile:Image/Resize/form.html.twig' handler_form: 'kit_file.image.resize.form.handler' library: 'imagine.gd' kitpages_file_system: file_system_list: kitpagesFile: local: directory_public: %kernel.root_dir%/../web directory_private: %kernel.root_dir% base_url: %base_url% 步骤5: php bin/vendors update 步骤6: 运行命令:php app/console kitFile:updateDatabase 扩展实体 ============ 查看实体 File 创建一个实体 - 类 Extendentity extends FileBase 创建一个仓库 - 类 ExtendentityRepository extends FileBaseRepository { CONST entity = 'AppSiteBundle:Extendentity'; } 完成 config.yml entity_file_name_list: default : class: Kitpages\FileBundle\Entity\File data_dir_prefix: /default Extendentity : class: App\SiteBundle\Entity\Extendentity data_dir_prefix: /ExtendentityDir