Image Server Upload
이미지 서버 업로드
How it works
- Specify upload options when initializing the editor.
- On image insertion, the editor automatically makes an AJAX request to the server.
- Once the request reaches the server, it stores the image and sends back to the client the link to the uploaded image.
Initialize the editor
First, add the imageUploadURL
option, as its value enter the upload destination for the images.
Next, set any additional options to configure upload methods and allowed file types: imageUploadParam
, imageUploadParams
, imageUploadMethod
, imageMaxSize
, imageAllowedTypes
.
<script> |
Receive the uploaded image and store it
Return the path to the uploaded image
Complete Example
<script> new FroalaEditor('.selector', { // Set the image upload URL. imageUploadURL: '/upload_image' }) </script> |
# Django from django.http import HttpResponse import json from froala_editor import Image from froala_editor import DjangoAdapter def upload_image(request): try: response = Image.upload(DjangoAdapter(request), '/public/') except Exception: response = {'error': str(sys.exc_info()[1])} return HttpResponse(json.dumps(response), content_type="application/json") |