后端代码

def upload(request):
    if request.method == "GET":
        return render(request,'upload.html')
    if request.method =="POST":
        pass

def upload_file(request):
    request.POST.get('username')
    fafafa = request.FILES.get('fileobj')
    img_path = os.path.join('static/img/',fafafa.name)
    with open( img_path, 'wb') as f:
        for item in fafafa.chunks():
            f.write(item)
    ret = {'code':True,'data':img_path}
    return HttpResponse(json.dumps(ret))
views.py

相关文章:

  • 2021-11-20
  • 2021-11-20
  • 2021-11-20
  • 2021-10-31
  • 2021-11-09
  • 2021-11-12
  • 2022-02-08
  • 2022-12-23
猜你喜欢
  • 2022-03-07
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
  • 2021-10-31
  • 2021-09-24
  • 2022-02-18
相关资源
相似解决方案