2017 © Pedro Peláez
 

yii-extension d1files

file uploader

image

dbrisinajumi/d1files

file uploader

  • Monday, March 23, 2015
  • by uldisn
  • Repository
  • 1 Watchers
  • 0 Stars
  • 59 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

d1files

Features

  • attach files to model record
  • widget for model view

Installation

  • install https://github.com/blueimp/jQuery-File-Upload?source=c
  • install https://github.com/DBRisinajumi/d2files.git
php composer.phar require dbrisinajumi/d1files dev-master
  • add to config/main.php
     'import' => array(
        'vendor.dbrisinajumi.d1files.models.*',
    ),
    'modules' => array(
        'd1files' => array(
             'class' => 'vendor.dbrisinajumi.d1files.D1filesModule',
             'upload_dir' => 'root.upload',
         ),  
     ),

Usage

controler

  • add to access rules follow actions: 'upload','deleteFile','downloadFile'
  • add actions
<?php

    public function actionUpload($model_id ) {

        Yii::import( "vendor.dbrisinajumi.d1files.compnents.*");
        $oUploadHandler = new UploadHandlerD1files(
                        array(
                            'model_name' => 'model....',
                            'model_id' => $model_id,
                            'accept_file_types' => '/\.(gif|pdf|dat|jpe?g|png)$/i',
                        )
        );

    }

    public function actionDeleteFile($id) {
        Yii::import( "vendor.dbrisinajumi.d1files.compnents.*");        
        UploadHandlerD1files::deleteFile($id);
    }

    public function actionDownloadFile($id) {

        $m = D1files::model();
        $model = $m->findByPk($id);
        if ($model === null) {
            throw new CHttpException(404, 'The requested record in d1files does not exist.');
        }

        Yii::import( "vendor.dbrisinajumi.d1files.compnents.*");
        $oUploadHandler = new UploadHandlerD1files(
                        array(
                            'model_name' => 'model....',
                            'model_id' => $id,
                            'download_via_php' => TRUE,
                            'file_name' => $model->file_name,
                        )
        );  
    }    

VIEW


$this->widget( 'TbDetailView', array( 'data' => $model, 'attributes' => array( array( 'label' => Yii::t('FuelingModule.crud', 'Attachments'), 'type' => 'raw', 'template' => $this->widget( 'vendor.dbrisinajumi.d1files.widgets.d1Upload', array( 'controler' => $this, 'model_id' => $model->getPrimaryKey(), 'action' => 'template', ), true ), 'value' => $this->widget("bootstrap.widgets.TbButton", array( "label"=>Yii::t("FuelingModule.crud_static","Add file"), "icon"=>"icon-plusthick", 'htmlOptions' => array( 'data-toggle' => 'modal', 'onclick' => '$("#fileupload").trigger("click");' ), ),true) , ),

The Versions

23/03 2015

dev-master

9999999-dev

file uploader

  Sources   Download

BSD-2-Clause

The Requires

 

yii widget files uploader phundament