I am using FilePond.js to allow users to drag and drop images on a website. I am trying to setup FilePond to retrieve user photo inputs. Apparently I am meant to put in the media link of where I want the photo to be uploaded to. Like so:
<script>
FilePond.registerPlugin(FilePondPluginImagePreview);
const inputElement = document.querySelector('input[type="file"]');
const pond = FilePond.create(inputElement);
FilePond.setOptions({
server: "#" *** I have tried everthing possible as a server option, nothing works***
});
</script>
def add(request):
if request.method == "POST":
product_title = request.POST.get("product_title")
product_price = request.POST.get("product_price")
product_description = request.POST.get("product_description")
product_images = request.FILES.getlist('filepond')
request.user.product_set.create(product_title = product_title,product_price =product_price, product_description = product_description, product_images = product_images)
return render(request,"main/add.html")
class product(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
product_title = models.CharField(max_length=100, blank=True)
product_price = models.CharField(max_length=30, blank=True)
product_description = models.CharField(max_length=1000, blank=True)
product_images = models.FileField()
But I can't seem to get FilePond to upload the images to the Django media url.
How can I point FilePond to upload to the url where my photo is meant to be stored?
The only way I know how to collect images from user inputs is with a get request. Also can I use a get request to just retrieve the users submitted FilePond images and upload them to the database that way?
P.S I am trying to point FilePond to upload it to the media url on my development server. Which is http://www.example.local:8000/media