uploadify

Hi Im relatively new to Yii and am playing around with the basic controller actions and so forth right now. At the moment I am trying to implement the uploadify extension in my test site. However, I am unsure how I can call the javascript so that I get the browse flash button.

I have tried


<input id="fileUpload" name="fileUpload" type="file" />

as suggested by the uploadify.com implementation however with no luck.

I have included the action in the site controller and it works as site/upload. I have also changed the UploadifyWidget view to point to the correct file locations.


<script type="text/javascript" src="<?php echo Yii::app()->baseUrl; ?>/js/jquery-1.3.2.min.js"></script>

<script type="text/javascript" src="<?php echo Yii::app()->baseUrl; ?>/js/jquery.uploadify.js"></script>

<script type="text/javascript">

$(document).ready(function() {

    $("#fileUpload").fileUpload({

        'uploader': '<?php echo Yii::app()->baseUrl; ?>/images/uploader.swf',

        'cancelImg': '<?php echo Yii::app()->baseUrl; ?>/images/cancel.png',

        'script': '<?php echo Yii::app()->baseUrl; ?>/index.php?r=site/upload',

        'folder': '<?php echo Yii::app()->baseUrl; ?>/images/gallery',

        'fileDesc': 'Image Files',

        'fileExt': '*.jpg;*.jpeg;*.gif;*.png',

        'multi': <?php echo $mult; ?>,

        'buttonText': 'agregar foto',

        'displayData': 'speed',

        'simUploadLimit': 1,

        'onComplete': complete,

        onError: function (a, b, c, d) {

        if (d.status == 404)

            alert('Could not find upload script. Use a path relative to: '+'<?= getcwd() ?>');

        else if (d.type === "HTTP")

           alert('error '+d.type+": "+d.status);

        else if (d.type ==="File Size")

           alert(c.name+' '+d.type+' Limit: '+Math.round(d.sizeLimit/1024)+'KB');

        else

           alert('error '+d.type+": "+d.text);

        },

    });



Im probably doing loads wrong but any help would be appreciated.

cheers!

Please post your widget call to view it a little more

The widget calls fine, I can see the javascript being rendered. See below:


$this->widget('application.extensions.uploadify.uploadifyWidget', array('mult'=>'false'));



just debug a bit more, check if is the right path to the uploader.swf button.

Hello, I try implement uploadify extension to my site, but it doesn’t work. I have problem with upload script.

I use this settings:


'script': 'index.php?r=site/upload',

and also i have this in my SiteController class:


public function actions()

	{

		return array(

			// captcha action renders the CAPTCHA image

			// this is used by the contact page

			'captcha'=>array(

				'class'=>'CCaptchaAction',

				'backColor'=>0xEBF4FB,

			),

                        'upload'=>'application.controllers.upload.UploadFileAction',

		);

	}

And always I get HTTP 403 error.

Can anyone help me please? THX

Error 403 Means that you dont’ have the rights to go to that page. It means that you have to edit the access for site/upload

Sory, the error is 404 and thanks for answer.

Have you edited .htaccess or the urlManager in the config/main.php?

No, I have clean yii blog webapp.

Did you ever solve this issue?

I’m also having trouble getting uploadify to find the controller.If i put a standalone php script and give the relative path it works fine but when i put index.php?r=controller/action it complains.

Does it have to do with the url configurations ar either the web server or yii ?

index.php works

index.php?r=controller/action returns script not found…enter a path relative to project local path(e.g./var/www/…/)

/index.php?r=controller/action return an error 302

whice i guess the last should be the correct one since getcwd() uploadify is alerting on failure doesnt end to a "/".