示例#1
0
文件: views.py 项目: Cruel/Anondex
def upload_image(request):
    if request.method == 'POST':
        try:
            user = request.user if request.user.id else None
            file = LibraryFile(user=user, ip=request.META['REMOTE_ADDR'])
            file.save_file(request.FILES['imagefile'])
            return HttpResponse(simplejson.dumps({'success':True, 'value':file.id}))
        except Exception, e:
            return HttpResponse(simplejson.dumps({'success':False, 'error':e.message}))
示例#2
0
文件: views.py 项目: Cruel/Anondex
def upload_file(request):
    # TODO: Limit user uploads to avoid upload bombing
    if request.method == 'POST':
        try:
            user = request.user if request.user.is_authenticated() else None
            file = LibraryFile(user=user, ip=request.META['REMOTE_ADDR'])
            file.save_file(request.FILES['file'])
            return addlibfile(request, file.id)
        except Exception, e:
            return HttpResponse(json.dumps({'success':False, 'error':e.message}))