So I’m trying to use an ajax file upload form with Django and running into an issue with FileIO. Specifically,
with BufferedWriter( FileIO( filename, "wb" ) ) as dest:
results in
ValueError: invalid mode: wb
I’m running Python 2.6/Django 1.3 locally on OSX 10.6.7. I tried chmod +X to the directory I’m targeting with the filename. Any idea what I’m missing? Thanks.
http://docs.python.org/release/2.6.6/library/io.html#raw-file-i-o
The “mode” is what you’re trying to set is where you use “rb,” which in the documentation isn’t a valid mode. Either way, the fact that it’s reading in raw data from a file seems to indicate that FileIO is set in binary mode by default–so the “b” seems unnecessary to me.