Multiple image upload using Django, Vuejs and Axiox

27 views
Skip to first unread message

Alam Khazi

unread,
Nov 20, 2021, 12:07:03 AM11/20/21
to django...@googlegroups.com
Hi,
By using Vuejs, Axiox and Django, Uploading multiple images. After uploading images are getting in list and then those list of images names we are storing into backend in ImageField image is saving into database but not saving into media folder.


['nature6.jpg', 'nature5.jpg', 'nature4.jpg', 'nature3.jpg', 'nature2.jpg', 'nature1.jpg', 'nature.jpg']
```
    if request.method == "POST":
        # From template we are fetching values
        data = json.loads(request.body)
images = data['images']
        saveform = vk_service(image=images[0],
image2=images[1],
 image3=images[2],
 image4=images[3],
 image5=images[4],
 image6=images[5],)
```
Images are saving into database but not saving in media folder.
Please help me out to solve this issue.

Thanks
~Salima

Omkar Parab

unread,
Nov 20, 2021, 1:19:05 AM11/20/21
to django...@googlegroups.com
Check, whether you've added "upload_to" in your Image Field and add MEDIA_ROOT & MEDIA_URL in settings.py file or not. 



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CABscGkSJ66hXxyOOZYfLSbaAH-Wc89QogQXX%3DVeMFheghJJp2A%40mail.gmail.com.

Gabo LaTo

unread,
Nov 20, 2021, 6:22:29 AM11/20/21
to django...@googlegroups.com
how are you sending the files from the client?
It seems to me you're reading the files metadata but you are not accessing the image binaries to store them.

Look at this example. It's made in angular but it can give you an idea:



In this case the backend is done with Django Rest Framework so just sending the data as the framework expected make it work: https://github.com/cardanovalley/cardano-directories-api/tree/setup-for-forms

--
Reply all
Reply to author
Forward
0 new messages