|
@@ -4608,27 +4608,17 @@ class System_Photo(ListView):
|
|
|
def get(self,request):
|
|
def get(self,request):
|
|
|
return render(request, 'backstageNet/systemSet/imageUpload.html', context={})
|
|
return render(request, 'backstageNet/systemSet/imageUpload.html', context={})
|
|
|
def post(self,request):
|
|
def post(self,request):
|
|
|
- guide_photo = request.FILES['upload']
|
|
|
|
|
- if guide_photo:
|
|
|
|
|
- print("新闻图片:", guide_photo)
|
|
|
|
|
- news_photo_dir = 'media/uploads/'
|
|
|
|
|
- end_name = guide_photo.name.split('.')[-1]
|
|
|
|
|
- # 判断如果路径不存在,即创建路径
|
|
|
|
|
- if os.path.exists(news_photo_dir) == False:
|
|
|
|
|
- os.makedirs(news_photo_dir)
|
|
|
|
|
- img = Image.open(guide_photo)
|
|
|
|
|
- now_time = time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))
|
|
|
|
|
- pic_name = now_time + '.' + end_name
|
|
|
|
|
- print("pic_name:", pic_name)
|
|
|
|
|
- img.save(news_photo_dir + pic_name)
|
|
|
|
|
- news_photo = news_photo_dir + pic_name
|
|
|
|
|
- print("new_photo:",news_photo)
|
|
|
|
|
- data = {"code": 0,"msg": "","data": {"src": news_photo}}
|
|
|
|
|
- else:
|
|
|
|
|
- new_photo = "0"
|
|
|
|
|
- data = {"code": 404,"msg": "","data": {"src": news_photo}}
|
|
|
|
|
- data = json.dumps(data)
|
|
|
|
|
- return HttpResponse(data)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ basestr = request.FILES.get("upload")
|
|
|
|
|
+ base_dir = 'media/uploads/'
|
|
|
|
|
+ now_time = time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))
|
|
|
|
|
+ if basestr:
|
|
|
|
|
+ img = Image.open(basestr)
|
|
|
|
|
+ img.save(base_dir + now_time +".png")
|
|
|
|
|
+ SystemPhoto.objects.create(name=base_dir +now_time +".png",pic_1=base_dir +now_time +".png")
|
|
|
|
|
+ return HttpResponse("1")
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
# 系统管理上传图片
|
|
# 系统管理上传图片
|