Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div id="dropzone-div">
- <form class = "dropzone" id = "image-form">
- {% csrf_token %}
- <div class="dropzone-previews"></div>
- <input type = "text" name = "album_Id" id = "album_Id" hidden>
- <div class="fallback">
- <input name="image_file" type="file" multiple="" />
- </div>
- <input type = "reset" id ="resetImageForm" hidden>
- </form>
- </div>
- <span><button class="btn btn-success" id = "upload">Upload</button></span>
- var myDropzone = new Dropzone(".dropzone", {
- url: "{% url 'upload' %}",
- addRemoveLinks: true,
- thumbnailWidth: "80",
- thumbnailHeight: "80",
- dictCancelUpload: "Cancel",
- parallelUploads: 100,
- autoProcessQueue: false
- });
- myDropzone.on("drop", function (event) {
- $('.dropzone').animate({
- opacity: 1,
- top: "-5"
- });
- });
- $("#upload").on('click', function () {
- myDropzone.processQueue();
- $.ajax({
- type: "POST",
- url: "{% url 'getPhoto' %}",
- dataType: "json",
- async: true,
- data: {
- album_Id_1:$("#album_Id").val()
- },
- success: function (json_data) {
- alert(json_data)
- }
- });
- });
- #module for uploading images
- @csrf_exempt
- def uploadImages(request):
- try:
- if request.session['member_id'] is not None:
- if request.method == "POST":
- album_Id = request.POST.get('album_Id','')
- files = request.FILES.getlist('file')
- for filename in files:
- save_image = AlbumPhotos(photo=filename, albumPhoto_id=album_Id)
- save_image.save()
- data = {'status':'true'}
- return HttpResponse(json.dumps(data), content_type="application/json")
- except KeyError:
- pass
- return redirect('/')
- #module for counting photos in current album
- @csrf_exempt
- def getPhotoCount(request):
- if request.session['member_id'] is not None:
- if request.method == "POST":
- response = {}
- album_Id = request.POST.get('album_Id_1','')
- countPhotos = AlbumPhotos.objects.filter(albumPhoto_id=album_Id).count()
- print("_______",countPhotos)
- response['count'] = countPhotos
- return HttpResponse(json.dumps(response), content_type="application/json")
- #except KeyError:
- # pass
- #return redirect('/')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement