On 11/7/06, Sanjay <[EMAIL PROTECTED]> wrote:
>
> Thanks a lot for the guidences.
>
> While trying "file_size = os.path.getsize(upload.file.name)," I get
> Exception: StringIO instance has no attribute 'name'.
>
> Seeing that upload has an attribute "length," I tried that too, but got
> -1.
>
> The code below worked, but I don't know whether it is the best way:
>
> data = upload.file.read()
> file_size = len(data)
>

This way is probably the best:

upload.file.seek(0, 2)
file_size = upload.file.tell()
upload.file.seek(0)

-bob

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to