django 批量上传图片文件保存在本地

class TestAPIView(ModelViewSet):
    def image_file(self, request,*args, **kwargs):
        files = request.FILES.getlist('files')
        path = r'C:\Users\Administrator\Desktop\image'
        for file in files:
            img_name=file.name
            test = file.file.read()
            with open(f'{path}'+'\\'+img_name,'wb') as f:
                f.write(test)
        return Response({'msg': '保存成功'})