Hellow, I try to use EAjaxUpload extention. I copy all files to extention directory and create widget:
class ImageUploadWidget extends CWidget
{
public $title='UploadFile';
public $visible=true;
public $image;
public function run()
{
if($this->visible)
{
$this->renderContent();
}
}
protected function renderContent()
{
$this->render('UploadForm');
}
}
the UploadForm.php is a view:
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
$options = array(
'id' => 'uploadimagewidget',
'options' => array(
'title' => 'Upload Image',
'autoOpen'=> false,
'modal' => true,
'width' => 450,
),
);
$this->beginWidget('zii.widgets.jui.CJuiDialog', $options);
?>
<body>
<div id="uploadButton" class="button">
<font>Загрузить</font>
</div>
<ol id="files">
Загруженные файлы :
</ol>
</body>
<?php
$this->widget('ext.EAjaxUpload.EAjaxUpload',
array(
'id'=>'uploadFile',
'config'=>array(
'action'=>'http://myshutternote.com/index.php?r=Picture/upload', //i have also tried '/Picture/upload', and 'Picture/upload/' and '/Picture/upload/'
'allowedExtensions'=>array("jpg"),//array("jpg","jpeg","gif","exe","mov" and etc...
'sizeLimit'=>10*1024*1024,// maximum file size in bytes
'minSizeLimit'=>10,// minimum file size in bytes
// 'onComplete'=>"js:function(id, fileName, responseJSON){ alert(fileName); }",
// 'messages'=>array(
// 'typeError'=>"{file} has invalid extension. Only {extensions} are allowed.",
// 'sizeError'=>"{file} is too large, maximum file size is {sizeLimit}.",
// 'minSizeError'=>"{file} is too small, minimum file size is {minSizeLimit}.",
// 'emptyError'=>"{file} is empty, please select files again without it.",
// 'onLeave'=>"The files are being uploaded, if you leave now the upload will be cancelled."
// ),
// 'showMessage'=>"js:function(message){ alert(message); }"
)
));
$this->endWidget('zii.widgets.jui.CJuiDialog');
?>
and the file PictureController.php:
public function actionUpload(){
Yii::import("ext.EAjaxUpload.qqFileUploader");
$folder='http://myshutternote.com/images/usergalleries/';// folder for uploaded files I have tried '/images/' and other, permissions are 777
$allowedExtensions = array("jpg");//array("jpg","jpeg","gif","exe","mov" and etc...
$sizeLimit = 10 * 1024 * 1024;// maximum file size in bytes
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
$result = $uploader->handleUpload($folder);
$result=htmlspecialchars(json_encode($result), ENT_NOQUOTES);
echo $result;// it's array
}
When I try to Upload an Image, I get the message ‘Failed’((
http://{site name}/index.php?r=Picture/upload - there no errors here