Yii Framework Forum: MUploadify - Yii Framework Forum

Jump to content

  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

MUploadify use uploadify uploader in your application Rate Topic: -----

#1 User is offline   Gustavo 

  • Master Member
  • Yii
  • Group: Moderators
  • Posts: 916
  • Joined: 27-July 10
  • Location:Curitiba - Brasil

Posted 20 August 2011 - 03:33 AM

Topic to discuss about the MUploadify extension

Any doubt, bugs, suggestions report here.

Thanks
--
Extensions:
translate modue - module to handle translations
multiActiveRecord - db selection in models
redisCache - redis cache component
mpCpanel - interact with cpanel api
mUploadify - use uploadify uploader in your application

Gustavo Salomé Silva
1

#2 User is offline   Gosaric 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 02-December 10
  • Location:Croatia

Posted 20 August 2011 - 11:32 AM

Good job :)

What about Uploadify events? How to use them? Answer -> http://www.yiiframew...nction-literal/
0

#3 User is offline   Gustavo 

  • Master Member
  • Yii
  • Group: Moderators
  • Posts: 916
  • Joined: 27-July 10
  • Location:Curitiba - Brasil

Posted 20 August 2011 - 05:34 PM

Hey Gosaric
Thanks!
I'll add this reference in the extension page

If you find any bug or have any suggestion, let me know

Cheers,
Gustavo
--
Extensions:
translate modue - module to handle translations
multiActiveRecord - db selection in models
redisCache - redis cache component
mpCpanel - interact with cpanel api
mUploadify - use uploadify uploader in your application

Gustavo Salomé Silva
0

#4 User is offline   mahen 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 04-August 11

Posted 22 August 2011 - 11:53 PM

i am trying to use this extentions but i am getting HTTP error, dont why

code is

//////////view

$this->widget('ext.widgets.uploadify.MUploadify',array(
'model'=>$model,
'attribute'=>'company_logo',
'script'=>$this->createUrl('producer/upload'),
'auto'=>true,
'folder'=>'/images/producer/logo',
'scriptData' => array('extraVar' => 1234, 'PHPSESSID' => session_id()),
//'uploadButton'=>true,
'callbacks' => array(
'onError' => 'function(evt,queueId,fileObj,errorObj){alert("Error: " + errorObj.type + "\nInfo: " + errorObj.info);}',
'onComplete' => 'function(){alert("Upload Completed");}',
'onCancel' => 'function(evt,queueId,fileObj,data){alert("Upload Cancelled");}',
)
//'someOption'=>'someValue',
));


////////////////// controller

//controller
function init(){
if(isset($_POST['SESSION_ID'])){
$session=Yii::app()->getSession();
$session->close();
$session->sessionID = $_POST['SESSION_ID'];
$session->open();
}
}
function actionUpload(){
$model=new Producer();
if(isset($_POST['Producer'])){
$model->company_logo=CUploadedFile::getInstance($model,'company_logo');
if(!$model->save())
throw new CHttpException(500);
$model->company_logo->saveAs('someFile.jpg');
Yii::app()->end();
}
}

ANy idea ?>>>>


View PostGustavo, on 20 August 2011 - 05:34 PM, said:

Hey Gosaric
Thanks!
I'll add this reference in the extension page

If you find any bug or have any suggestion, let me know

Cheers,
Gustavo

0

#5 User is offline   Gustavo 

  • Master Member
  • Yii
  • Group: Moderators
  • Posts: 916
  • Joined: 27-July 10
  • Location:Curitiba - Brasil

Posted 23 August 2011 - 01:43 AM

Hi
I can't see any error, but this is a few considerations

you don't need to pass the session id, the plugin does it automatically

you don't need to specify the folder option as the file will be treated by the script

when you specify a callback function, prepend 'js:' to its value, like

'onError' => 'js:function(evt,queueId,fileObj,errorObj){alert("Error: " + errorObj.type + "\nInfo: " + errorObj.info);}',

I believe the callback methods shouldn't be in a callback array, try to remove
'callbacks' => array(

if this doesn't work, post the error so I can see
--
Extensions:
translate modue - module to handle translations
multiActiveRecord - db selection in models
redisCache - redis cache component
mpCpanel - interact with cpanel api
mUploadify - use uploadify uploader in your application

Gustavo Salomé Silva
0

#6 User is offline   waterloomatt 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 546
  • Joined: 09-April 10

Posted 23 August 2011 - 02:42 AM

Looks good - will try it on next project.
0

#7 User is offline   Gosaric 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 02-December 10
  • Location:Croatia

Posted 24 August 2011 - 09:20 AM

regards,

I had a strange error with this extension. Upload and everything works great, but if you upload a file and let's say "actionUpload" controller does not return false then the progress bar does not work. Before it worked, quite a strange thing.

Details:

  $this->widget('ext.uploadify.MUploadify', array(
      'name' => 'Photo',
      'buttonText'=>t('Upload photos'),
      'script'=>array('photo/upload'),
      'fileExt' => '*.jpg;*.png;',
      'scriptData' => array('id'=>$_GET['id']),
      'method' => 'post',
      'multi' => true,
      'auto' => true,
//      'onComplete' => "js:function (event, ID, fileObj, response, data) {
//        alert('asd');
//      }",
      'onAllComplete' => "js:function (event, data) {
        alert('bla');
        $('body').loadCropper('/set/photos/id/".$_GET['id']."');
      }",
      'onError' => "js:function (event,ID,fileObj,errorObj) {
        alert('Error: ' + ID + errorObj.type + errorObj.info);
      }",
  ));


  public function actionUpload() {

    if (isset($_POST['Photo'])) {
      

      $imageoriginal = CUploadedFile::getInstanceByName('Photo');

(.....................)

      if ($imageoriginal->saveAs($location)) {


      }
    }
    return false; /* Without this line progress bar doesnt work*/
  }


Folder creation, resize, upload and everything works, but removing "return false" results with no progress bar and no events after upload (onComplete etc.)...

there is one little problem with "return false":

2011/08/24 16:08:48 [error] [exception.CHttpException.400] exception 'CHttpException' with message 'Your request is invalid.' in \yii-1.1.8.r3324\framework\web\CController.php:328


Edit: solution: in controller put echo true; :D
0

#8 User is offline   Gustavo 

  • Master Member
  • Yii
  • Group: Moderators
  • Posts: 916
  • Joined: 27-July 10
  • Location:Curitiba - Brasil

Posted 24 August 2011 - 10:27 AM

Thanks Godaric!
I did notice it was broken sometimes but didn't know why.

Already updated the extension page with your fix
--
Extensions:
translate modue - module to handle translations
multiActiveRecord - db selection in models
redisCache - redis cache component
mpCpanel - interact with cpanel api
mUploadify - use uploadify uploader in your application

Gustavo Salomé Silva
0

#9 User is offline   QueryTom 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 20-June 11

Posted 21 October 2011 - 04:03 PM

Hello,

i have problems getting scriptData entry to my controller and i hope someone can help me.

Here is my code:

// view
<?php
$this->widget('ext.uploadify.MUploadify',array(
  'name'=>'galleriaPicture',
  'buttonText'=>Yii::t('application','Browse'),
  'script'=>array('galleria/upload'),
  'scriptData'=>array('pageView_id'=>Yii::app()->request->getQuery('view')),
  'method'=>'post',
  'fileExt'=>'*.jpg;*.png;',
  'uploadButton'=>true,
  'multi'=>true,
  'sizeLimit'=>602400,
  'uploadButtonTagname'=>'button',
 
));
?>
 
// controller
...

      if(isset($_POST['galleriaPicture'])){
        $queryString_id = json_decode($_POST['pageView_id']);
        $galleriaPicture=CUploadedFile::getInstanceByName('galleriaPicture');
        $uploadedPicture = $galleriaPicture->getName('galleriaPicture');
        $galleriaPicture_url = 'images/gallery/'.$queryString_id.'/'.$uploadedPicture;
       
        if(!$galleriaPicture->saveAs($galleriaPicture_url))
        throw new CHttpException(500);
    echo 1;
   
    Yii::app()->end();

...


My view outputs:

/*<![CDATA[*/
$('#galleriaPicture').uploadify({'script':'/nueva/backend.php?r=galleria/upload','uploader':'/nueva/assets/d9927f4f/uploadify.swf','expressInstall':'/nueva/assets/d9927f4f/expressInstall.swf','cancelImg':'/nueva/assets/d9927f4f/cancel.png','fileDataName':'galleriaPicture','buttonText':'Browse','scriptData':{'galleriaPicture':'{\"pageView_id\":\"test\"}','SESSION_ID':''},'folder':'/nueva/assets/d9927f4f','fileExt':'*.jpg;*.png;','multi':true,'sizeLimit':602400});
/*]]>*/


But the uploaded files will always be uploaded to the images/gallery/ directory, instead of the images/gallery/test/ directory.

I'm not sure about how to handle the scriptData option, any help will be great!
0

#10 User is offline   waterloomatt 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 546
  • Joined: 09-April 10

Posted 21 October 2011 - 08:44 PM

Can you confirm that $queryString_id === 'test'?
0

#11 User is offline   QueryTom 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 20-June 11

Posted 22 October 2011 - 04:41 AM

View Postwaterloomatt, on 21 October 2011 - 08:44 PM, said:

Can you confirm that $queryString_id === 'test'?


Hi, thanks for your reply!

What is the best practice to proof that? I tried some if constructs, but it fails. Seems like $queryString_id is NULL:


I'm sure that json_decode($_POST[pageView_id]) is NULL

 
 $queryString_id = json_decode($_POST["pageView_id"];
 if ($queryString_id === NULL)
        {
              Yii::app()->user->setFlash('fail','QueryString is NULL');           
        }
        else
        {
              Yii::app()->user->setFlash('fail','QueryString is not NULL');
        }


returns "QueryString is NULL"

 
 $queryString_id = 'hello';
 if ($queryString_id === NULL)
        {
              Yii::app()->user->setFlash('fail','QueryString is NULL');           
        }
        else
        {
              Yii::app()->user->setFlash('fail','QueryString is not NULL');
        }


returns "QueryString is not NULL"

This post has been edited by QueryTom: 22 October 2011 - 04:54 AM

0

#12 User is offline   Gustavo 

  • Master Member
  • Yii
  • Group: Moderators
  • Posts: 916
  • Joined: 27-July 10
  • Location:Curitiba - Brasil

Posted 22 October 2011 - 07:50 AM

check the content of the post data
$postData=print_r($_POST,true);
Yii::log('script Data:'.$postData);//using file cache
Yii::app()->user->setFlash('fail','script Data'.$postData);//or as you are using

--
Extensions:
translate modue - module to handle translations
multiActiveRecord - db selection in models
redisCache - redis cache component
mpCpanel - interact with cpanel api
mUploadify - use uploadify uploader in your application

Gustavo Salomé Silva
0

#13 User is offline   QueryTom 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 20-June 11

Posted 22 October 2011 - 07:56 AM

The content of $_POST is:

( [Filename] => Lighthouse.jpg 
[fileext] => *.jpg;*.png; [SESSION_ID] => b0bdnhvbco2k0ed785irfl63d3 
[folder] => /nueva/assets/d9927f4f 
[galleriaPicture] => {"pageView_id":"test"} 
[Upload] => Submit Query ) 

0

#14 User is offline   Gustavo 

  • Master Member
  • Yii
  • Group: Moderators
  • Posts: 916
  • Joined: 27-July 10
  • Location:Curitiba - Brasil

Posted 23 October 2011 - 09:22 AM

      if(isset($_POST['galleriaPicture'])){
        $queryString_id = json_decode($_POST['galleriaPicture']);
        $galleriaPicture=CUploadedFile::getInstanceByName('galleriaPicture');
        $uploadedPicture = $galleriaPicture->getName('galleriaPicture');
        $galleriaPicture_url = 'images/gallery/'.$queryString_id['pageView_id'].'/'.$uploadedPicture;
       
        if(!$galleriaPicture->saveAs($galleriaPicture_url))
        throw new CHttpException(500);
    echo 1;
   
    Yii::app()->end();

should do it

--
Extensions:
translate modue - module to handle translations
multiActiveRecord - db selection in models
redisCache - redis cache component
mpCpanel - interact with cpanel api
mUploadify - use uploadify uploader in your application

Gustavo Salomé Silva
0

#15 User is offline   QueryTom 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 20-June 11

Posted 23 October 2011 - 11:04 AM

View PostGustavo, on 23 October 2011 - 09:22 AM, said:

      if(isset($_POST['galleriaPicture'])){
        $queryString_id = json_decode($_POST['galleriaPicture']);
        $galleriaPicture=CUploadedFile::getInstanceByName('galleriaPicture');
        $uploadedPicture = $galleriaPicture->getName('galleriaPicture');
        $galleriaPicture_url = 'images/gallery/'.$queryString_id['pageView_id'].'/'.$uploadedPicture;
       
        if(!$galleriaPicture->saveAs($galleriaPicture_url))
        throw new CHttpException(500);
    echo 1;
   
    Yii::app()->end();

should do it


Thanks Gustavo!

I solved it that way:
        $decodeData = json_decode($_POST['galleriaPicture']);
        $queryString_id_url = $decodeData->pageView_id;        
        $galleriaPicture=CUploadedFile::getInstanceByName('galleriaPicture');
        $uploadedPicture = $galleriaPicture->getName('galleriaPicture');
        $galleriaPicture_url = 'images/gallery/'.$queryString_id_url.'/'.$uploadedPicture; 

0

#16 User is offline   mbabineau 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 31
  • Joined: 07-June 11
  • Location:San Diego, CA

Posted 04 November 2011 - 03:47 PM

Hi All -

I've been looking at this Uploadify extension and it definitely looks a bit better than the other one in the extensions section. I've run into a problem though, with overriding the event for Uploadify.

Example:

Try to add an 'onOpen' or 'onComplete' event to your widget instanciation....for me, this isn't working, I see the key/values showing up in the outputted javascript at the bottom of the page, but the events are not making it back to Uploadify, or Uploadify doesn't know how to read them properly. I have a feeling this could just be an encoding problem or escaped characters.

Sample JS from my rendered HTML page:

<script type="text/javascript">/*<![CDATA[*/$('#videoUpload').uploadify({'script':'/manage/media/upload','uploader':'/assets/31bd69e5/uploadify.swf','expressInstall':'/assets/31bd69e5/expressInstall.swf','cancelImg':'/assets/31bd69e5/cancel.png','fileDataName':'videoUpload','buttonText':'Select a file','scriptData':{'videoUpload':' ','SESSION_ID':'a2ejd3hlc86mat05ld206vk9a3'},'folder':'/assets/31bd69e5','multi':true,'onOpen':'console.log(\"testing\")'});jQuery(function($) {jQuery('#yw0').yiiListView({'ajaxUpdate':['yw0'],'ajaxVar':'ajax','pagerClass':'pager','loadingClass':'list-view-loading','sorterClass':'sorter'});});/*]]>*/</script>



So this should just make a console log when it runs, but......no dice!

Anyone see behavior like this before?

Thanks,
Matt
0

#17 User is offline   mbabineau 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 31
  • Joined: 07-June 11
  • Location:San Diego, CA

Posted 04 November 2011 - 03:49 PM

Nevermind, I just noticed I was missing "JS:" in front of the javascript on the override!

Cheers -
Matt
0

#18 User is offline   Renaud 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 49
  • Joined: 04-October 11

Posted 08 November 2011 - 01:50 PM

Hi there,

I'd like to know why my actionUpload() action handler is not hit by the debugger ? The file is stored as expected so the actionUpload() code is definitely executed. But also why is my flash message not displayed ?

Here's my code:

    
//view
    $this->widget('application.extensions.uploadify.MUploadify', array(            
            'name' => 'myPicture',
            'buttonText'=>'Upload your Diploma',
            'script'=> array('client/upload'),
            'fileExt'=>'*.jpg;*.png;',            
            'auto'=>true,
    ));

//controller
      function actionUpload() {
        
        if (isset($_POST['myPicture'])) {
            
            $myPicture = CUploadedFile::getInstanceByName('myPicture');
            if (!$myPicture->saveAs('someFile.ext')){
                throw new CHttpException(500);
            }
            else{
                Yii::app()->user->setFlash('success', "Data1 saved!");
            }
            echo 1;
            Yii::app()->end();
        }
    }
    ?>


Any idea ?

Renaud
0

#19 User is offline   Gustavo 

  • Master Member
  • Yii
  • Group: Moderators
  • Posts: 916
  • Joined: 27-July 10
  • Location:Curitiba - Brasil

Posted 08 November 2011 - 01:59 PM

HI Renaud
It is because the request is sent by a flash application (uploadify.swf), therefore it does not save cookies, and flash messages are stored as cookies
If possible, use the onAllComplete to display a message for the user, or store the message someway else
'onAllComplete'=>'js:function(){
  $("#myMessageField").html("Data saved! ");
}'

--
Extensions:
translate modue - module to handle translations
multiActiveRecord - db selection in models
redisCache - redis cache component
mpCpanel - interact with cpanel api
mUploadify - use uploadify uploader in your application

Gustavo Salomé Silva
1

#20 User is offline   Renaud 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 49
  • Joined: 04-October 11

Posted 09 November 2011 - 03:47 PM

Hi Gustavo,

Thanks for your quick reply.

For for some reason, as soon as I add the property 'onAllComplete' the "black upload button" is replaced by the standard HTML file input, so it's not possible to upload in one go. Even if I had the Upload link it does not work...

My code is this :

        $this->widget('application.extensions.uploadify.MUploadify', array(            
            'name' => 'myPicture',
            'buttonText'=>'Upload your Diploma',
            'script'=> array('client/upload'),
            'fileExt'=>'*.jpg;*.png;',            
            'auto'=>true,
            'onAllComplete' => 'js:function(){$("#myMessageField").html("Data saved! ");',
        ));


Am I missing something ?

Cheers
Renaud
0

Share this topic:


  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • 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