실제로 연결된 파일 업로드 가이드를 사용하여 photologue에 적용했습니다. 캔버스 요소에서 base64 데이터 URL을 추출하고 설정했습니다. 그 값을 폼의 필드는 내가보기에 장고의 서버 측에서 해석 할 수 :
def upload_base64(request):
# Handle file upload
if request.method == 'POST':
form = PhotoCodeForm(request.POST, request.FILES)
if form.is_valid():
uploaded_photo_data = base64.b64decode(request.POST['photocode'])
uploaded_photo_file = ContentFile(uploaded_photo_data)
title_str = "Untitled"
slug = slugify(title_str + str(datetime.now()))
uploaded_photo = Photo.objects.create(image = default_storage.save(slug, uploaded_photo_file),
title = slug,
title_slug = slug)
name_upload_gallery = "user-upload-queue"
try:
upload_gallery = Gallery.objects.get(title_slug__exact=name_upload_gallery)
except ObjectDoesNotExist:
return HttpResponseBadRequest('<html><body><p>The gallery "'+name_upload_gallery+'" does not exist.</p></body></html>')
upload_gallery.photos.add(uploaded_photo)
# Redirect to the photo gallery after POST
return HttpResponseRedirect('/canvas/')
else:
return HttpResponseBadRequest('<html><body><p>The entered data was not correct.</p></body></html>')
else:
form = PhotoCodeForm() # A empty, unbound form
return render_to_response(
'photologue_upload/upload_base64.html',
{'form': form},
context_instance=RequestContext(request)
)
upload_base64.html는 base64로 문자열에 붙여 필드 photocode을 가진 매우 단순한 형태입니다
. 당신은 대답을 찾았습니까? 나는 똑같은 문제가 있습니다 .. – PhilBot
그래, 이걸 구현할 수 있었다. 아르 자형. 나는 대답을 쓰려고 노력할 것이다 ... – kossmoboleat