<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2769" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>You should use the getContentType() method - look
in the zope book (API - File).</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Jonathan</FONT></DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=mjakowlew@gmail.com href="mailto:mjakowlew@gmail.com">Mike
Jakowlew</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=zope@zope.org
href="mailto:zope@zope.org">zope@zope.org</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Tuesday, November 15, 2005 9:25
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [Zope] Problems using forms to
upload files to Zope</DIV>
<DIV><BR></DIV>Here's what I'm trying to accomplish:<BR><BR>1. The user fills
out a form page with various fields<BR>2. The user selects a file to
upload<BR>3. when the user hits submit two things should
happen:<BR> - The file selected is uploaded
<BR> - all the filled out form fields are
written to the database (MS SQL)<BR><BR>This is my current problem:<BR>The
writting to the database part works fine on it's own, but when combined with
the file upload I get this error <BR><BR><STRONG
style="FONT-WEIGHT: normal">Error Type: AttributeError</STRONG><BR><STRONG
style="FONT-WEIGHT: normal">Error Value: 'NoneType' object has no attribute
'headers'</STRONG><BR><BR><BR>My code:<BR><BR>*********HTML
FORM**********<BR><html><BR><h1
tal:content="template/title">title</h1> <BR><p>Fill out the
form below to update the website with the appropriate
info:</p><BR><BR><form action="uploadForm.py"><BR><table
width="100%" border="0" cellspacing="0" cellpadding="0"> <BR>
<tr><BR> <td width="16%" height="27"
align="right"><strong>Your Dept:
</strong></td><BR> <td
width="84%"><input type="text" name="department"></td>
<BR> </tr><BR> <tr><BR> <td
height="27" align="right"><strong>Document
Title:</strong></td><BR> <td><input
type="text" name="title"></td> <BR> </tr><BR>
<tr><BR> <td height="30"
align="right"><strong>Filename:</strong></td><BR>
<td><input type="file" name="upload_filename" ></td>
<BR> </tr><BR> <tr><BR> <td
height="28" align="right"><strong>Version of File
:</strong></td><BR> <td><input
type="text" name="version"></td> <BR> </tr><BR>
<tr><BR> <td height="28"
align="right"><strong>URL:</strong></td><BR>
<td><input type="text" name="url"></td> <BR>
</tr><BR> <tr><BR> <td height="33"
align="right"><strong>Owner
Approved:</strong></td><BR> <td><input
type="text" name="ownerapp"></td> <BR> </tr><BR>
<tr><BR> <td align="right"><strong>ISO
Approved:</strong></td><BR> <td><input
type="text" name="isoapp"></td><BR> </tr> <BR>
<tr><BR> <td height="41"
align="right"><strong>Comments:
</strong></td><BR> <td
rowspan="2"><textarea name="comments" cols="60" rows="5">
<BR>
</textarea></td><BR> </tr><BR>
<tr><BR> <td height="85" align="right"
valign="top">&nbsp;</td><BR>
</tr><BR> <tr><BR> <td height="29"
align="right"><strong>Date</strong></td><BR>
<td><input type="text" name="date"></td><BR>
</tr><BR> <tr> <BR> <td height="62"
align="right"></td><BR>
<td><p><BR> <input type="submit"
id="submit" name="submit" /><BR>
<BR> </p> <BR>
</td><BR>
</tr><BR></table><BR><p><BR><BR></form><BR><hr><BR><p>Return
to the <a href="NewsTable">News
page</a></p><BR></html><BR><BR>******uploadForm.py********<BR><BR>def
writeDB():<BR> # get sql method<BR>
insert=container['insert_fileapps']<BR><BR>
REQUEST=context.REQUEST<BR> <BR>
department = REQUEST.form.get('department')<BR> title =
REQUEST.form.get('title')<BR> filename =
REQUEST.form.get('upload_filename')<BR><BR>
content_type=filename.headers['Content-Type']<BR> if
content_type.find('image')!=-1:<BR>
context.manage_addImage(id, file, title) <BR>
else:<BR> context.manage_addFile(id,
file, title)<BR> return 'Finished'<BR><BR>
version = REQUEST.form.get('version')<BR> url =
REQUEST.form.get('url')<BR> ownerapp =
REQUEST.form.get('ownerapp') <BR> isoapp =
REQUEST.form.get('isoapp')<BR> comments =
REQUEST.form.get('comments')<BR> date =
REQUEST.form.get('date')<BR><BR>
filename=id<BR> filename =
filename.split('\\')[-1]<BR><BR> # call it, passing
arguments <BR> insert( department=department, title=title,
filename=filename, version=version, url=url, ownerapp=ownerapp, isoapp=isoapp,
comments=comments, date=date)<BR><BR> # return a
confirmation page<BR> page=container['
thanks.html']<BR> return
page()<BR><BR><BR>writeDB()<BR><BR>************************<BR><BR>Any help
provided would be greatly appreciated<BR>Thanks in
advance,<BR>mjakowlew<BR><BR>************************<BR>PS: I'm sorry if I
went about posting this in the wrong spot or the wrong way, I'm new to this
<BR>
<P>
<HR>
<P></P>_______________________________________________<BR>Zope maillist
-
Zope@zope.org<BR>http://mail.zope.org/mailman/listinfo/zope<BR>**
No cross posts or HTML encoding! **<BR>(Related lists -
<BR> http://mail.zope.org/mailman/listinfo/zope-announce<BR> http://mail.zope.org/mailman/listinfo/zope-dev
)<BR></BLOCKQUOTE></BODY></HTML>