python+django+cfUpdate上传

前台:

 #html页面:

前台页面照抄官网就行 把 js里面的challs_flash_update()这个函数的 a.url = "/Image/index/upload/";改成后台接收路径

html里面object标签的 embed src="/static/js/sourceinterfacejs/update.swf"路径改了

后台:(主要是request.FILES.get('Filedata',None)获取传过来的文件,文件是一个一个传的)

    form = request.FILES.get('Filedata',None)
    path = 'static/media'
    if not os.path.exists(path):
        os.makedirs(pathname)
    file_name = pathname+'/'+form.name
    destination = open(file_name, 'wb+')
    for chunk in form.chunks():
        destination.write(chunk)
    destination.close()
    return HttpResponse({'ok'})

 

posted on 2014-12-03 17:16  ChrisPaul  阅读(243)  评论(0编辑  收藏  举报