Sorry... I can't deal with all the SPAM so until I can find a better solution for the forums, I'm locking them down. For now please use awesome services like stackoverflow.com for community support. Thanks.
This forum is a community forum meant for users of the plugin to collaborate and help solve issues with implementation, etc. Unfortunately, as the creator of the plugin, I do not have much time to attend to every request here as this is only a side project and I must work a full-time job to provide for my family. This is how I keep the Flash version free and the HTML5 version low cost.
Uploadify 3.0 Beta with Django
  • New to uploadify and thought I'd try it with Django. Took a bit to figure it out, so thought I would post my results in case it helps anyone else.

    In my javascript initialization:
    $('#my_upload_button').uploadify({
    swf: '/my/media/lib/uploadify.swf',
    uploader: '/myapp/uploadurl',
    cancelImage: '/my/media/images/uploadify-cancel.png',
    checkExisting: false,
    postData: {sessionid: $.cookie('sessionid')},
    auto: true
    });

    (Note the sessionid in the postData - learned this from http://stackoverflow.com/questions/1348669/uploading-multiple-files-with-django)

    On Django, I created a middleware

    from django.conf import settings
    from django.core.urlresolvers import reverse

    class SWFUploadMiddleware(object):
    def process_request(self, request):
    if (request.method == 'POST') and (request.path == reverse('myapp.views.myFileHandler')) and \
    request.POST.has_key(settings.SESSION_COOKIE_NAME):
    request.COOKIES[settings.SESSION_COOKIE_NAME] = request.POST[settings.SESSION_COOKIE_NAME]


    And added this to my settings:
    MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'myapp.middleware.swfupload.SWFUploadMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    ...
    )


    And added the url:
    urlpatterns = patterns('',
    ('^myapp/uploadurl$', myFileHandler),
    ...
    )


    And added the view:
    from django.http import HttpResponse
    from django.shortcuts import render_to_response
    def myFileHandler(request):
    if request.method == 'POST':
    for field_name in request.FILES:
    uploaded_file = request.FILES[field_name]

    # write the file into /tmp
    destination_path = '/tmp/%s' % (uploaded_file.name)
    destination = open(destination_path, 'wb+')
    for chunk in uploaded_file.chunks():
    destination.write(chunk)
    destination.close()

    # indicate that everything is OK for SWFUpload
    return HttpResponse("ok", mimetype="text/plain")

    else:
    # show the upload UI
    return render_to_response('uploads/manual.html')


    And finally got it to work.

    Many thanks go to http://blog.fogtunes.com/2009/11/howto-integrate-swfupload-with-django/
  • The user and all related content has been deleted.
  • I also followed the blog post, and my code is the same, however I still can't get it to work. I successfully add a value to request.COOKIE in middleware, however something in CSRF still fails. Any ideas?
  • Hi, you could share this project? I need SWFUpload or came with package of Uploadify3?

    Thanks!