[Zope] Upload file size

Dieter Maurer dieter@handshake.de
Sun, 17 Dec 2000 10:21:46 +0100 (CET)


diego@magicwebdesign.com.br writes:
 > There's a way to get the size of a file uploaded in a form before write it?
I am not sure, what type of object is used at the base of
"FileUpload" objects (to give them there file like behaviour).

If this a "cStringIO" objects, they may have a "len" attribute.
This means, you could use "your_uploaded_file.len" to get the
length.

Otherwise, you could try:

	   file.seek(0,2)	# positions at the end
	   len= file.tell()     # tells the current position (i.e. the length)
	   file.seek(0,0)	# positions at the start

That's Python code.
You can do something equivalent in several DTML commands.


Dieter