Search - User list
Full Version: Uploading files corrupted on windows bug and suggested fix
Root » Bugs » Uploading files corrupted on windows bug and suggested fix
1
kiwi_NZ
Hi all,

Okay, I think I have found the source of this problem.

In djangobb_forum/forms.py about line 112 there is the line

file(path, 'w').write(memfile.read())
which I changed to
file(path, 'wb').write(memfile.read())

and then also in djangobb_forum/views.py about line 789

file_data = file(attachment.get_absolute_path()).read()

I changed to
file_data = file(attachment.get_absolute_path(), 'rb').read()

These file modes is what was corrupting the attachment upload and download on windows. Changing the files to be accessed in binary mode in windows seems to have fixed the problem.

Regards
Kiwi_NZ



slav0nic
Ooops, Tnx)
commited
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB