index.html
<form method="POST" action="." enctype="multipart/form-data">
{% csrf_token %}
{{ image_form.as_p }}
<input type="submit" name="submit" value="Search via Image">
</form>
forms.py
class UploadImageForm(forms.Form):
image_field = forms.ImageField(required=False)
views.py
if request.method == 'POST':
if request.POST.get('submit') == 'Search via Image':
print(request.POST)
print(request.FILES)
So I want to take the image uploaded by the user and save it in my storage, perform a few operations on it, display it on the webpage and delete it. But I am not being able to go this.
In request.POST I'm getting a dict containing the file name, but that's plain text. And while using request.FILES I'm getting,
<MultiValueDict: {}>
How should I go about this? Thanks, in advance.