When someone clicks Submit after selecting a file with the <input type="file"> element, how do I access the contents of the file in Django?
(It seems like the request sent to the request handler has no trace of the file anywhere — not even in request.FILES.)
Currently my template is like:
<form method="post" enctype="multipart/form-data">
<input type="file" enctype="multipart/form-data" name="file" accept="text/csv"/>
<input type="submit" value="Upload" />
</form>
View:
def HandleRequest(request):
print "**** request:", request
I don’t see anything being printed about the file.
Note:
There’s probably other ways to do this in Django, but I’m looking a solution using the simple input tag, and not something else (which would probably involve Javascript).
The code you posted, as it is posted, works fine. The HTML is sound (though I think the
enctypeon the<input>is redundant at best), and a very simple view shows anInMemoryFileafter the POST. The problem must lie in something between the browser and your view. Some things to check:mod_wsgiconfiguration.