I am fairly new to Django. I've created a simple template page to test a service I'm writing. The service does two things - accepts a file through POST, and accepts a string path to the file through POST. This is more of a template question.
I've figured out how to send the file content itself, but sending the file path WITHOUT the file data from the template page is something I haven't been able to wrap my mind around. The operation of the template page's file path submission should be the same as the file submission: the user picks a file and hits submit, but only the text path should be submitted, not the file data.
Any help is appreciated!
<h1>File Upload</h1>
<form action="upload/file/" method="post" enctype="multipart/form-data">
<p>{{ form.non_field_errors }}</p>
<p>{{ form.docfile.label_tag }} {{ form.docfile.help_text }}</p>
<p>
{{ form.docfile.errors }}
{{ form.docfile }}
<p><input type="submit" value="Upload" />
</form>
<br>
<h1>Path Upload</h1>
<form action="upload/path/" method="post" enctype="application/x-www-form-urlencoded">
<p>{{ form.non_field_errors }}</p>
<p>{{ form.docfile.label_tag }} {{ form.docfile.help_text }}</p>
<p>
{{ form.docfile.errors }}
{{ form.docfile }}
<p><input type="submit" value="Upload" />
</form>
</body>
</html>
And if anyone wants to see if, the forms.py I'm using.
from django import forms
class UploadFileForm(forms.Form):
docfile = forms.FileField(
label='Select a file',
help_text='max. 42 megabytes')