if(isset($_FILES['img_url'])){
<code>
но толка один фиг некого таже ошибка.
<?php
/* @var $this MyGalleryController */
/* @var $model MyGallery */
/* @var $form CActiveForm */
?>
<div class="form">
<?php
$form = $this->beginWidget('CActiveForm', array(
'id' => 'my-gallery-form',
'htmlOptions' => array(
// 'enctype' => 'multipart/form-data',
// 'class' => 'dropzone',
),
));
?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model, 'description'); ?>
<?php echo $form->textField($model, 'description', array('size' => 60, 'maxlength' => 255)); ?>
<?php echo $form->error($model, 'description'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model, 'img_url'); ?>
<div id="dropZed" class="dropzone"></div>
<?php echo $form->error($model, 'img_url'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model, 'position'); ?>
<?php echo $form->textField($model, 'position'); ?>
<?php echo $form->error($model, 'position'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model, 'visible'); ?>
<?php echo $form->textField($model, 'visible'); ?>
<?php echo $form->error($model, 'visible'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Создать' : 'Сохранить', array(
'name'=>'submit', 'id' => 'sb-all'
)); ?>
</div>
<script>
$(function() {
var dzone = new Dropzone("#dropZed", {
paramName: "img_url",
url: "/admin/MyGallery/ImagesUpload",
method: "files",
autoProcessQueue: false,
addRemoveLinks: true,
init: function() {
var submitButton = document.querySelector("#sb-all");
dzone = this; // closure
submitButton.addEventListener("click", function() {
dzone.processQueue(); // Tell Dropzone to process all queued files.
});
}
});
Dropzone.autoDiscover = false;
});
</script>
<?php $this->endWidget(); ?>
</div><!-- form -->
$(function() {
var dzone = new Dropzone("#dropZed", {
paramName: "img_url",
url: "/admin/MyGallery/ImagesUpload",
method: "files",
autoProcessQueue: false,
addRemoveLinks: true,
init: function() {
var submitButton = document.querySelector("#sb-all");
dzone = this; // closure
submitButton.addEventListener("click", function() {
dzone.processQueue(); // Tell Dropzone to process all queued files.
});
}
});
Dropzone.autoDiscover = false;
});
public function actionImagesUpload(){
$model = new MyGallery;
if(!empty($_FILES['img_url'])){
if($_FILES['img_url']['error'] == 0){
move_uploaded_file($_FILES['img_url']['tmp_name'],
Yii::app()->request->baseUrl . 'images/upload/' . $_FILES['img_url']['name']);
}}
$model->img_url = $_FILES['img_url']['name'];
$model->save();
}
<?php
/* @var $this MyGalleryController */
/* @var $model MyGallery */
/* @var $form CActiveForm */
?>
<div class="form">
<?php
$form = $this->beginWidget('CActiveForm', array(
'id' => 'my-gallery-form',
'htmlOptions' => array(
'enctype' => 'multipart/form-data',
// 'class' => 'dropzone',
),
'enableAjaxValidation' => false,
));
?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model, 'description'); ?>
<?php echo $form->textField($model, 'description', array('size' => 60, 'maxlength' => 255)); ?>
<?php echo $form->error($model, 'description'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model, 'img_url'); ?>
<div id="dropZed" class="dropzone"></div>
<?php echo $form->error($model, 'img_url'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Создать' : 'Сохранить', array(
'name'=>'submit',
)); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
<script>
var dzone = new Dropzone("#dropZed", {
paramName: "img_url",
url: "/admin/MyGallery/create"
method: "files"
});
Dropzone.autoDiscover = false;
</script>
картинку заливает но её имя не сохраняет, хотя в низу есть $model->save(0). кажется истина где-то рядом.