Has anyone used Uploadify ?

uploadify is a multiple file uploading JQuery plugin.

i know there is an uploadify addon for Yii, but it is really tedious to use. one has to make an extension out of it.

<code>

$(’#file_upload’).uploadify({

‘uploader’ : '/uploadify/uploadify.swf,

‘scriptAccess’:‘always’,

‘script’ : ‘/uploadify/uploadify.php’,

‘cancelImg’ : ‘/uploadify/cancel.png’,

‘buttonImg’ : ‘/uploadify/select.gif’,

</code>

The above setting works and the files can be uploaded and shown correctly. However it is no good to use the static script file ‘uploadify.php’ to process the uploaded files. I need to use my own action in one of my controllers to handle and process the uploaded files (follow the MVC practice). Thus i need to set the ‘script’ attribute to ‘/upload/processFile’, in which upload is controller and processFile is an action in the controller. But when i do this, uploadify always gives a ‘HTTP error’ and no file is uploaded.

Could you please tell me what i should do to make it work right?

thank you very much!

the problem is that you are not authenticated, as flash requests don’t send cookies

try this extension

http://www.yiiframework.com/extension/muploadify/

any doubt let me know

thank you very much Gustavo,

however is it possible to use uploadify in MVC anyway not as an extension?

for example, is it possible to let uploadify swf send cookies to Yii scripits , or let Yii agree with uploadify to run without a cookie?

hi Gustavo,

i follow up my experiments.

when i changed the script attribute of uploadify to my controller/action like this:

<code>

$(’#file_upload’).uploadify({

‘uploader’ : '/uploadify/uploadify.swf,

‘scriptAccess’:‘always’,

‘script’ : ‘/upload/fileProcess’,

‘cancelImg’ : ‘/uploadify/cancel.png’,

‘buttonImg’ : ‘/uploadify/select.gif’,

</code>

where upload/fileProecess is the controller/action pair.

If i write the action method this way:




public function actionFileProcess()

{

		echo 'whatever';

		Yii::app()->end();

           //comment away all other codes

}



there will be no ‘http error’ and the string ‘whatever’ can be passed to the ‘response’ variable of uploadify. this seems indicating that flash request can reach controller/action without cookie. the problem is that one can not really do anything in the action method since it can only echo a string and end.

So you probably have an error in your code below




       	//comment away all other codes



to test it, create a file field and upload a file normally without using uploadify and you will see the error, or change the log type of your application to "file" and check the runtime folder for the error file

as for the cookie and authentication, if you need it, you can send the session id as scriptData and start another session in the response using this session id

you can see how its done in the extension page I sent you