uploading files to file system/zipping/downloading problems

Jordan jordan.taylor2 at gmail.com
Sun Aug 20 21:51:34 EDT 2006


Assuming your upload_file.file.read() function works, the overwriting
should be the only issue.  Just want to point out that total_data +=
data is not advisable for this example (speed/efficiency issue,
although i'm sure it could probably be even faster than what I replace
it with if u decided to use arrays, but it's probably not worth it XD),
and I think open() was replaced by file(), although they're probably
interchangable.

new code
-----------------
total_data = ' '
temp_data = []
while True:
    data = upload_file.file.read(8192)
    if not data:
        break
    temp_data.append(data)
total_data = ' '.join(temp_data)
somefile = file(target_file_name, 'wb')
somefile.write(total_data)
f.close()
-------------------

OriginalBrownster wrote:
> I am currently uploading a file from a users computer to the file
> system on my server using python, just reading the file and writing the
> binaries.
>
>         total_data=' '
>         while True:
>             data = upload_file.file.read(8192)
>             if not data:
>                 break
>             total_data += data
>             f = open(target_file_name, 'wb')
>             f.write(total_data)
>             f.close
>
> However when i download the file from the server it is not intact and
> it cannot be opened. It is happening with every type of file.
>
> It seemed to be working before and now it is..maybe I goofed up and
> deleted something.
> However I can't seem to find it.
> 
> any ideas??




More information about the Python-list mailing list