Problem with EAjaxUpload

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

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((

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

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

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.

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

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

public function actionUpload()


{





        Yii::import(&quot;ext.EAjaxUpload.qqFileUploader&quot;);





        &#036;folder= './uploads/';// folder for uploaded files


        &#036;allowedExtensions = array(&quot;flv&quot;,&quot;avi&quot;,&quot;mov&quot;,&quot;3gp&quot;,&quot;mp3&quot;);//array(&quot;jpg&quot;,&quot;jpeg&quot;,&quot;gif&quot;,&quot;exe&quot;,&quot;mov&quot; and etc...


        &#036;sizeLimit = 50 * 1024 * 1024;// maximum file size in bytes


        &#036;uploader = new qqFileUploader(&#036;allowedExtensions, &#036;sizeLimit);


        &#036;result = &#036;uploader-&gt;handleUpload(&#036;folder);


        //


        //first do these operations


        &#036;fileSize=filesize(&#036;folder.&#036;result['filename']);//GETTING FILE SIZE


        &#036;fileName=&#036;result['filename'];//GETTING FILE NAME


        


        //then save to db if necessary


        &#036;video = new Videos();


        &#036;video-&gt;filename = &#036;fileName;


        &#036;video-&gt;filesize = &#036;fileSize;


        &#036;video-&gt;save();


        


        //then prepare the json result set.


        &#036;result=htmlspecialchars(json_encode(&#036;result), ENT_NOQUOTES);


        


        echo &#036;result;// it's array


}

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/’;

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

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'=&gt;'uploadFile',


    'config'=&gt;array(


           'action'=&gt;Yii::app()-&gt;createUrl('/&#46;&#46;/images'),


           'allowedExtensions'=&gt;array(&quot;jpg&quot;),//array(&quot;jpg&quot;,&quot;jpeg&quot;,&quot;gif&quot;,&quot;exe&quot;,&quot;mov&quot; and etc...


           'sizeLimit'=&gt;10*1024*1024,// maximum file size in bytes


          // 'minSizeLimit'=&gt;1*102*102,// minimum file size in bytes


           //'onComplete'=&gt;&quot;js:function(id, fileName, responseJSON){ alert(fileName); }&quot;,


           //'messages'=&gt;array(


           //                  'typeError'=&gt;&quot;{file} has invalid extension. Only {extensions} are allowed.&quot;,


           //                  'sizeError'=&gt;&quot;{file} is too large, maximum file size is {sizeLimit}.&quot;,


           //                  'minSizeError'=&gt;&quot;{file} is too small, minimum file size is {minSizeLimit}.&quot;,


           //                  'emptyError'=&gt;&quot;{file} is empty, please select files again without it.&quot;,


           //                  'onLeave'=&gt;&quot;The files are being uploaded, if you leave now the upload will be cancelled.&quot;


           //                 ),


           //'showMessage'=&gt;&quot;js:function(message){ alert(message); }&quot;


          )

)); ?>

controller part:

public function actionUpload()

    {





    Yii::import(&quot;ext.EAjaxUpload.qqFileUploader&quot;);





    &#036;folder=Yii::app()-&gt;basePath.'/&#46;&#46;/images/';// folder for uploaded files


	


    &#036;allowedExtensions = array(&quot;jpg&quot;);//array(&quot;jpg&quot;,&quot;jpeg&quot;,&quot;gif&quot;,&quot;exe&quot;,&quot;mov&quot; and etc...


    &#036;sizeLimit = 10 * 1024 * 1024;// maximum file size in bytes


    &#036;uploader = new qqFileUploader(&#036;allowedExtensions, &#036;sizeLimit);


    &#036;result = &#036;uploader-&gt;handleUpload(&#036;folder);


   





    &#036;fileSize=filesize(&#036;folder.&#036;result['filename']);//GETTING FILE SIZE


    &#036;fileName=&#036;result['filename'];//GETTING FILE NAME


	 &#036;result = htmlspecialchars(json_encode(&#036;result), ENT_NOQUOTES);





    echo &#036;result;// it's array

}

Thanks in advance.

I have a same problem, help…

For who it may help:

The code in qqFileUploader.php:


private function checkServerSettings(){

        $postSize = $this->toBytes(ini_get('post_max_size'));

        $uploadSize = $this->toBytes(ini_get('upload_max_filesize'));


        if ($postSize < $this->sizeLimit || $uploadSize < $this->sizeLimit){	

            $size = max(1, $this->sizeLimit / 1024 / 1024) . 'M';

            die("{'error':'increase post_max_size and upload_max_filesize to $size'}");

        }

    }

checks if the maximum file size in bytes that you specified is larger than the server limits

So for example if you used


'sizeLimit'=>10*1024*1024,// maximum file size in bytes

and the setting of post_max_size is 8M, no matter if you try to upload small file, it will fail