<!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>&nbsp;</div>
  <div>def PythonScript1(afile=None):<br>
&nbsp;&nbsp;&nbsp; '''<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; read file info<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; afile is name of HTML INPUT TAG<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HTML FORM AS FOLLOWS<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;FORM ACTION="PythonScript1" METHOD="POST"
enctype="multipart/form-data"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;INPUT TYPE="file" NAME="afile"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;INPUT TYPE="submit" VALUE="OK"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/FORM&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NOTE: without [enctype] file will be transerred as string<br>
&nbsp;&nbsp;&nbsp; '''<br>
&nbsp;&nbsp;&nbsp; afile.seek(0,2) #move to end<br>
&nbsp;&nbsp;&nbsp; bytes=afile.tell()<br>
&nbsp;&nbsp;&nbsp; afile.seek(0) #rewind</div>
  <div>&nbsp;&nbsp;&nbsp; #optional--converto to KB/MB<br>
&nbsp;&nbsp;&nbsp; megs=bytes / 1048576.0<br>
&nbsp;&nbsp;&nbsp; if megs &gt; 1:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "%.2f MB" % megs<br>
&nbsp;&nbsp;&nbsp; k=bytes / 1024.0<br>
&nbsp;&nbsp;&nbsp; if k &gt; 1:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "%d K" % k<br>
&nbsp;&nbsp;&nbsp; print "%d bytes" % bytes<br>
&nbsp;&nbsp;&nbsp; return printed<br>
&nbsp;&nbsp;&nbsp; <br>
  <br>
  <b><i>AnThu Nguyen <a class="moz-txt-link-rfc2396E" href="mailto:Anthu.Nguyen@Sun.COM">&lt;Anthu.Nguyen@Sun.COM&gt;</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>