vue 图片上传(一)

https://www.mscto.com/python/178498.html

使用django做后台,接收图片

def logo_upload(request):

    if request.method == 'POST':
        name = request.body
        file =request.FILES['file']
        # pic = request.FILES.get('')  # 获取图片

        wb = xlrd.open_workbook(
            filename=None, file_contents=request.FILES['file'].read())
        print("file_contents",type(request.FILES['file'].read()))
        print("file_contents",len(request.FILES['file'].read()))
        table = wb.sheets()[0]
        row = table.nrows
        for i in range(1, row):
            col = table.row_values(i)
            print(col)

        # style = request.data.get('data')

        # image = request.data.get('file')
        # pic = request.FILES.get('avator')

        print("upload")
        print(file)
        # print(name)
        ret = {
            "code": 20000,
            "data": {
            }

        }
        return JsonResponse(ret)
posted @ 2020-12-28 15:41  鲁哒哒  阅读(156)  评论(0编辑  收藏  举报