首页 > 解决方案 > 如何在 django 临时目录位置上传大文件?

问题描述

这是我试图做的:

def handle_uploaded_file(f):
    with open('/home/arvind/Desktop/newupload/documents/'+f.name, 'wb') as destination:
        filepath = destination.name
        for chunk in f.chunks():
           #time.sleep(1)
           destination.write(chunk)


def fileupload(request):
    if request.method == 'POST':
        files = request.FILES.getlist('uploadfile')
        for f in files:
            handle_uploaded_file(f)
        return HttpResponse('add')
    return HttpResponse("done")

标签: pythondjango

解决方案


推荐阅读