Yii Framework Forum: Problem with EAjaxUpload - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Problem with EAjaxUpload Rate Topic: ***** 1 Votes

#1 User is offline   nabiullin11 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 22-May 11

Posted 06 September 2011 - 07:19 AM

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
0

#2 User is offline   kosenka 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 05-October 09

Posted 06 September 2011 - 07:56 AM

View Postnabiullin11, on 06 September 2011 - 07:19 AM, said:

PictureController.php:
public function actionUpload(){
...
    	$folder='http://myshutternote.com/images/usergalleries/';// folder for uploaded files I have tried '/images/' and other, permissions are 777 
...
	}


When I try to Upload an Image, I get the message 'Failed'((
http://{site name}/index.php?r=Picture/upload - there no errors here

You have wrong folder to save file upload - variable $folder.
You must specify a folder on your server, like: /home/var/www/site.com/public_html/upload/
0

#3 User is offline   nabiullin11 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 22-May 11

Posted 06 September 2011 - 08:17 AM

View Postkosenka, on 06 September 2011 - 07:56 AM, said:

You have wrong folder to save file upload - variable $folder.
You must specify a folder on your server, like: /home/var/www/site.com/public_html/upload/


I change to the $folder='/public_html/myshutternote.ru/images/usergalleries/'
But the problem is the same((
0

#4 User is offline   sonam 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 79
  • Joined: 10-September 11

Posted 03 October 2011 - 01:08 AM

i have also some questions about this ext:
1)how can i save my files in the database
2)how to put validation that atleast one image is necessary to get uploaded please help
0

#5 User is offline   sonam 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 79
  • Joined: 10-September 11

Posted 03 October 2011 - 07:32 AM

I am able to do both:put in validations and created thumbnails also.....yipeeeee and also able to save files in database
0

#6 User is offline   dfu 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 28-July 11
  • Location:Madrid, Spain

Posted 26 December 2011 - 06:01 PM

Hi,

How did you manage to get this fixed? I always get failed.

Seems that, in my case, its related with the filesize function. If i comment it out it works.
0

#7 User is offline   arnO 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 04-January 12

Posted 08 February 2012 - 05:40 AM

Is that your folder (/home/var/www/site.com/public_html/upload/) is writable (777) ?
0

#8 User is offline   Ashok Poudel 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 02-March 12

Posted 16 March 2012 - 12:01 AM

View Postdfu, on 26 December 2011 - 06:01 PM, said:

Hi,

How did you manage to get this fixed? I always get failed.

Seems that, in my case, its related with the filesize function. If i comment it out it works.


i just figured out a problem while extracting the file info . hope it will help someone.


public function actionUpload()
{

Yii::import("ext.EAjaxUpload.qqFileUploader");

$folder= './uploads/';// folder for uploaded files
$allowedExtensions = array("flv","avi","mov","3gp","mp3");//array("jpg","jpeg","gif","exe","mov" and etc...
$sizeLimit = 50 * 1024 * 1024;// maximum file size in bytes
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
$result = $uploader->handleUpload($folder);
//
//first do these operations
$fileSize=filesize($folder.$result['filename']);//GETTING FILE SIZE
$fileName=$result['filename'];//GETTING FILE NAME

//then save to db if necessary
$video = new Videos();
$video->filename = $fileName;
$video->filesize = $fileSize;
$video->save();

//then prepare the json result set.
$result=htmlspecialchars(json_encode($result), ENT_NOQUOTES);

echo $result;// it's array
}
0

#9 User is offline   Manoj M 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 31
  • Joined: 09-September 12
  • Location:Dharapuram

Posted 30 November 2012 - 05:37 AM

First change ur php.ini upload_max_size and post_max_size....
while using the extension go to the extension folder then qqFileUploader
if ($postSize < $this->sizeLimit || $uploadSize < $this->sizeLimit) change it to
if ($postSize > $this->sizeLimit || $uploadSize > $this->sizeLimit)
u ll get it done ... still if u dont get then go create a folder 'upload' in ur baseurl then
in action upload give this $folder=Yii::getPathOfAlias('webroot').'/upload/';
0

#10 User is offline   ghadfrf 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 13-May 14

Posted 26 June 2014 - 05:46 AM

I tried all methods but i still get the failed eror,please can anyone help me.
0

#11 User is offline   ghadfrf 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 13-May 14

Posted 26 June 2014 - 06:20 AM

Whichever image extensions i use getting the same error,changed php.ini,and also sizelimit,also 3rd option but still same error is coming....help me soon struggling from two days.....

Here is my code
view part:

<?php $this->widget('ext.EAjaxUpload.EAjaxUpload',
array(
'id'=>'uploadFile',
'config'=>array(
'action'=>Yii::app()->createUrl('/../images'),
'allowedExtensions'=>array("jpg"),//array("jpg","jpeg","gif","exe","mov" and etc...
'sizeLimit'=>10*1024*1024,// maximum file size in bytes
// 'minSizeLimit'=>1*102*102,// 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); }"
)
)); ?>




controller part:
public function actionUpload()
{

Yii::import("ext.EAjaxUpload.qqFileUploader");

$folder=Yii::app()->basePath.'/../images/';// folder for uploaded files

$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);


$fileSize=filesize($folder.$result['filename']);//GETTING FILE SIZE
$fileName=$result['filename'];//GETTING FILE NAME
$result = htmlspecialchars(json_encode($result), ENT_NOQUOTES);

echo $result;// it's array
}


Thanks in advance.
0

#12 User is offline   deviasi 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 21-May 14

Posted 04 September 2014 - 04:22 AM

I have a same problem, help.....
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users