<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<tt>Roberto,<br>
<br>
This is perfect - exactly what I needed!<br>
<br>
Thanks,<br>
AnThu<br>
</tt><br>
Roberto Benitez wrote On 08/02/06 01:50 PM,:
<blockquote
cite="mid20060802205031.58797.qmail@web31009.mail.mud.yahoo.com"
type="cite">
<div>Try the following:</div>
<div> </div>
<div>def PythonScript1(afile=None):<br>
'''<br>
read file info<br>
afile is name of HTML INPUT TAG<br>
HTML FORM AS FOLLOWS<br>
<FORM ACTION="PythonScript1" METHOD="POST"
enctype="multipart/form-data"><br>
<INPUT TYPE="file" NAME="afile"><br>
<INPUT TYPE="submit" VALUE="OK"><br>
</FORM><br>
NOTE: without [enctype] file will be transerred as string<br>
'''<br>
afile.seek(0,2) #move to end<br>
bytes=afile.tell()<br>
afile.seek(0) #rewind</div>
<div> #optional--converto to KB/MB<br>
megs=bytes / 1048576.0<br>
if megs > 1:<br>
print "%.2f MB" % megs<br>
k=bytes / 1024.0<br>
if k > 1:<br>
print "%d K" % k<br>
print "%d bytes" % bytes<br>
return printed<br>
<br>
<br>
<b><i>AnThu Nguyen <a class="moz-txt-link-rfc2396E" href="mailto:Anthu.Nguyen@Sun.COM"><Anthu.Nguyen@Sun.COM></a></i></b> wrote:</div>
<blockquote class="replbq"
style="border-left: 2px solid rgb(16, 16, 255); padding-left: 5px; margin-left: 5px;">Hi,<br>
<br>
I'm trying to get the size of a file uploaded via an HTML form before <br>
it's written. "context.REQUEST.file" only accesses the file name, not <br>
the content. How do I read the contents? Any help will be much
appreciated.<br>
<br>
TIA,<br>
AnThu<br>
_______________________________________________<br>
Zope maillist - <a class="moz-txt-link-abbreviated" href="mailto:Zope@zope.org">Zope@zope.org</a><br>
<a class="moz-txt-link-freetext" href="http://mail.zope.org/mailman/listinfo/zope">http://mail.zope.org/mailman/listinfo/zope</a><br>
** No cross posts or HTML encoding! **<br>
(Related lists - <br>
<a class="moz-txt-link-freetext" href="http://mail.zope.org/mailman/listinfo/zope-announce">http://mail.zope.org/mailman/listinfo/zope-announce</a><br>
<a class="moz-txt-link-freetext" href="http://mail.zope.org/mailman/listinfo/zope-dev">http://mail.zope.org/mailman/listinfo/zope-dev</a> )<br>
</blockquote>
<br>
<p> </p>
<hr size="1">Do you Yahoo!?<br>
Get on board. <a
href="http://us.rd.yahoo.com/evt=40791/*http://advision.webevents.yahoo.com/handraisers">You're
invited</a> to try the new Yahoo! Mail Beta.
</blockquote>
</body>
</html>