123456789101112131415161718192021222324 |
- # -*-coding:utf-8 -*-
- import traceback
- from django.views.decorators.csrf import csrf_exempt
- from common import JsonResponse,params,save_bs64img_local
- # Create your views here.
- @csrf_exempt
- @params
- def upload_img(request):
- req_params = request.PARAMS
- if req_params:
- try:
- img_data = req_params.get("img_data")
- img_url = save_bs64img_local(img_data)
- if img_url:
- return JsonResponse({"code": 0, "img_url":img_url})
- else:
- return JsonResponse({"code": -1,"msg":u"图片上传失败!"})
- except:
- traceback.print_exc()
- else:
- return JsonResponse({"code": -1, "msg": u"缺少参数"})
|