I am writing a web app and I need to read a text file that a user will upload.
I will not need to store it in a database; the app only performs simple operations on the text in the file.
I'm currently uploading the file with <input type=file" name="input_file" id="file-in"> in a form submitted via POST and running this in main.py:
user_file = self.request.get("input_file")
print user_file
print type(user_file)
Output when I tried to upload a file ("foo.txt") with the contents "The quick brown fox jumps over the lazy dog!":
foo.txt
<type 'unicode'>
Why did this happen? How can I access the contents of the file?
Any help is appreciated. If you need some background info, I wrote this simple encryptor/decryptor app, and I'm trying to add the ability to upload a file instead of just copy-pasting the text in.