python后端接收前端回传的文件

filename=None

    if request.method == 'POST' and request.FILES.get('file'):

        from django.core.files.storage import FileSystemStorage

        myfile = request.FILES['file']

        fs = FileSystemStorage()

        filename = fs.save(myfile.name, myfile)

你可能感兴趣的:(python)