1

I'm trying to get Uploadify to work but I always get a http status code 302.

My jQuery looks like this:

$('#file_upload').uploadify({
        'swf'      : '<?php echo $this->basePath('/swf/uploadify.swf') ?>',
        'uploader' : '<?php echo $this->url('my-module', array('action'=>'uploadify')) ?>',
        'debug': true,
        'preventCaching'  : false
    });

When I call my action via the browser it works. When I call the swf via browser, I get a 200 - so it works as well.

I checked the uploadify-forum but their solutions either don't work or are related to ZF1 specifica...

2
  • You know, what "302" means? Thats nothing bad by itself ;) Commented Jan 8, 2013 at 12:12
  • I know that but it's not working and interpreted as error. Therefore it's quite bad :) Commented Jan 8, 2013 at 12:18

2 Answers 2

1

this is a flash cookie bug,the solution is restart session

note: I only tested on unix/linux

 class Module
{
    public function onBootstrap($e)
    {
        $eventManager = $e->getApplication()->getEventManager();
        $eventManager->attach(\Zend\Mvc\MvcEvent::EVENT_DISPATCH, array($this, 'onApplicationPreDispacth'), 100);

    }

    public function onApplicationPreDispacth($e)
    {
         $session_name = session_name();

         if (isset($_POST[$session_name])) {
              session_destroy();
              session_id($_POST[$session_name]);
              session_start();
         }
    }

Priority of this function must high than a one you posted a 302 redircti

and in javascript:

$('#file_upload2').uploadify({
        'buttonText' : 'select files',
        'swf'      : '/static/lib/uploadify/uploadify.swf',
        'uploader' : '/service/upload',
        'auto'     : true,
        'formData' : voice : {"<?php echo session_name();?>" : "<?php echo session_id(); ?>",'source':'voice'}
        } 
        // Put your options here
    });

use uploadify in zend framework 2 I worte this just then

Sign up to request clarification or add additional context in comments.

Comments

0

I solved the problem just using another uploader. Flash uploading is out-of-date anyway so I just used: http://blueimp.github.com/jQuery-File-Upload/

If you take the basic install it just works (I kept the uploadify upload function). The only drawback is that you have to design the uploading kinda manually... but not that tricky if you are familiar with Bootstrap and jQuery.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.