uploadify scriptData problem

Posted by elpaso66 on Stack Overflow See other posts from Stack Overflow or by elpaso66
Published on 2009-11-24T16:27:39Z Indexed on 2010/05/23 8:40 UTC
Read the original article Hit count: 1095

Filed under:

Hi, I'm having problems with scriptData on uploadify, I'm pretty sure the config syntax is fine but whatever I do, scriptData is not passed to the upload script.

I tested in both FF and Chrome with flash v. Shockwave Flash 9.0 r31

This is the config:

    $(document).ready(function() {
    $('#id_file').uploadify({
        'uploader'          : '/media/filebrowser/uploadify/uploadify.swf',
        'script'            : '/admin/filebrowser/upload_file/',
        'scriptData'        : {'session_key': 'e1b552afde044bdd188ad51af40cfa8e'},
        'checkScript'       : '/admin/filebrowser/check_file/',
        'cancelImg'         : '/media/filebrowser/uploadify/cancel.png',
        'auto'              : false,
        'folder'            : '',
        'multi'             : true,
        'fileDesc'          : '*.html;*.py;*.js;*.css;*.jpg;*.jpeg;*.gif;*.png;*.tif;*.tiff;*.mp3;*.mp4;*.wav;*.aiff;*.midi;*.m4p;*.mov;*.wmv;*.mpeg;*.mpg;*.avi;*.rm;*.pdf;*.doc;*.rtf;*.txt;*.xls;*.csv;',
        'fileExt'           : '*.html;*.py;*.js;*.css;*.jpg;*.jpeg;*.gif;*.png;*.tif;*.tiff;*.mp3;*.mp4;*.wav;*.aiff;*.midi;*.m4p;*.mov;*.wmv;*.mpeg;*.mpg;*.avi;*.rm;*.pdf;*.doc;*.rtf;*.txt;*.xls;*.csv;',
        'sizeLimit'         : 10485760,
        'scriptAccess'      : 'sameDomain',
        'queueSizeLimit'    : 50,
        'simUploadLimit'    : 1,
        'width'             : 300,
        'height'            : 30,
        'hideButton'        : false,
        'wmode'             : 'transparent',
        translations        : {
                              browseButton: 'BROWSE',
                              error: 'An Error occured',
                              completed: 'Completed',
                              replaceFile: 'Do you want to replace the file',
                              unitKb: 'KB',
                              unitMb: 'MB'
        }
    });
    $('input:submit').click(function(){
        $('#id_file').uploadifyUpload();
        return false;
    });
});

I checked that other values (file name) are passed correctly but session_key is not.

This is the decorator code from django-filebrowser, you can see it checks for request.POST.get('session_key'), the problem is that request.POST is empty.

def flash_login_required(function):
    """
    Decorator to recognize a user  by its session.
    Used for Flash-Uploading.
    """

    def decorator(request, *args, **kwargs):
        try:
            engine = __import__(settings.SESSION_ENGINE, {}, {}, [''])
        except:
            import django.contrib.sessions.backends.db
            engine = django.contrib.sessions.backends.db
        print request.POST
        session_data = engine.SessionStore(request.POST.get('session_key'))
        user_id = session_data['_auth_user_id']
        # will return 404 if the session ID does not resolve to a valid user
        request.user = get_object_or_404(User, pk=user_id)
        return function(request, *args, **kwargs)
    return decorator

© Stack Overflow or respective owner

Related posts about uploadify