Code Monkey home page Code Monkey logo

yii2-fileapi-widget's Introduction

WARNING: This extension is not more maintained (The base JS script FileAPI was deprecated)

Yii2 FileAPI widget.

This widget is a Yii 2 wrapper of FileAPI plugin.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist vova07/yii2-fileapi-widget "*"

or add

"vova07/yii2-fileapi-widget": "*"

to the require section of your composer.json file.

Usage:

// MyController.php

use vova07\fileapi\actions\UploadAction as FileAPIUpload;
...

public function actions()
{
    return [
        'fileapi-upload' => [
            'class' => FileAPIUpload::className(),
            'path' => '/path/to/temp/files'
        ]
    ];
}
// MyModel.php

use vova07\fileapi\behaviors\UploadBehavior;
...

public function behaviors()
{
    return [
        'uploadBehavior' => [
            'class' => UploadBehavior::className(),
            'attributes' => [
                'preview_url' => [
                    'path' => '/path/to/previews',
                    'tempPath' => '/path/to/temp/files/previews',
                    'url' => '/url/to/previews'
                ],
                'image_url' => [
                    'path' => '/path/to/images',
                    'tempPath' => '/path/to/temp/files/images',
                    'url' => '/url/to/images'
                ]
            ]
        ]
    ];
}
// _form.php

use vova07\fileapi\Widget as FileAPI;
...

echo $form->field($model, 'preview_url')->widget(
    FileAPI::className(),
    [
        'settings' => [
            'url' => ['/controller/fileapi-upload']
        ]
    ]
);

yii2-fileapi-widget's People

Contributors

acardinale avatar makroxyz avatar saochico avatar vova07 avatar webdevsega avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yii2-fileapi-widget's Issues

Events

Небольшой вопрос.
Почему событие FileAPI filecomplete добавляет в массив свою обработку?
https://github.com/vova07/yii2-fileapi-widget/blob/master/Widget.php#L387
Это задумка или опечатка?

Например, у меня результат загрузки файла выдается в другом формате, чем предполагает виджет - мой ответ "стандартизирован" в масштабах проекта.
После аплоада - я назначаю ID загруженного файла свойству модели.
Но, поскольку стандартный обработчик добавляется последним - он "перебивает" значение нужного поля на пустое.

Переназначить event filecomplete в этом случае будет легче, чем создавать и переопределять целый метод класса виджета.

не хватает возможности настройки параметров preview

Отличный виджет, спасибо! не хватает возможности настройки параметров preview

временно для себя доработал так
if(!empty($this->settings['preview'])) {
$this->_defaultSingleSettings['elements']['preview'] = $this->settings['preview'];
}
$this->_defaultSettings = $this->_defaultSingleSettings;

isAttributeChanged doesn't work

Привет

Возникла проблема, у меня существует модель в которой объявлено public поле picture_url, само поле хранится в json, после afterFind я делаю его развертку и присваиваю значение полю picture_url, при save велаю соответсвенно наоборот.

Виджет отлично работает при создании модели, в том числе и сохраняется изображение, все ок, но при редактировании возникает ошибка.

А именно, не загружается изображенее, вернее как, оно загружается но только в папку tempPath, а дальше нет. При этом у меня сохраняется имя файла и если его вручную перенести в path, то все нормально.

Обнаружил что проблема связана с проверкой if ($this->owner->isAttributeChanged($attribute))

Как временное решение, убрал isAttributeChanged и в принципе все работает. Но было бы хорошо исправить это цивилизованым способом и в репозитории.

How to use to upload images

Can you help me, How to use to upload multiple (images or files) ???
using yii2-fileapi-widget
please help guys !!!

Хотелки

  1. Добавить мультизагрузку
  2. Добавить возможность нарезки вариации для каждого изображения(это позволит всегда сохранить оригинал изображения и в случаях редизайна проекта нарезать новые вариации)

Загрузка php-скрипта

Здравствуйте!
Столкнулся с проблемой, когда злоумышленник загрузил php-скрипт в папку с изображениями.
Не знаю, как ему это удалось, но загрузка происходит через fileapi-widget.
Может быть у вас будут какие-то рекомендации, как защититься от этого.

Спасибо.

Coposer can't find package

php composer.phar require --prefer-dist vova07/yii2-fileapi-widget "*"

Result:

  Problem 1
    - The requested package vova07/yii2-fileapi-widget could not be found in any version, there may be a typo in the package name.

Не понятно как использовать

Делаю как в инструкции. Неплохо было бы добавить что в модель нужно добавить preview_url и image_url.
Так вот куда и как сохранить фотки?
Openserver . сайт localhost\gameproj
в модели

    public function behaviors()
    {
        return [
            'uploadBehavior' => [
                'class' => UploadBehavior::className(),
                'attributes' => [
                    'preview_url' => [
                        'path' => 'gameproj/previews',
                        'tempPath' => 'gameproj/temp/files/previews',
                        'url' => 'gameproj/previews'
                    ],
                    'image_url' => [
                        'path' => 'gameproj/images',
                        'tempPath' => 'gameproj/temp/files/images',
                        'url' => 'gameproj/images'
                    ]
                ]
            ]
        ];
    }

или настройки под линукс и на винде их не повторить?

Multiple input clarification

2
1

I have written normal scripting in the form to get multiple input fields as shown above images.
Is it possible in yii2-fileapi-widget same as above

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.