Django處理前端上傳的文件

file = request.FILES.get('img')獲取文件對象file
file.name能夠獲取文件名code

file = request.FILES.get('img')
with open('static/img/' + file.name, 'wb') as fp:
    for chunk in file.chunks():
        fp.write(chunk)
相關文章
相關標籤/搜索