Okay I corrected:<br><br><form action="uploadForm.py" method="post" enctype="multipart/form-data"><br><br>and also tried the getContentType, but I get the error:<br><br><strong style="font-weight: normal;">
Error Type: AttributeError</strong><br>
<strong style="font-weight: normal;">Error Value: FileUpload instance has no attribute 'getContentType'<span style="font-weight: bold;"><br></span><br>****uploadForm.py****<br>def content_type(self):<br> return
self.getContentType()<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> upload_contents= content_type(filename)<br><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></strong><br><br><div><span class="gmail_quote">On 11/15/05, <b class="gmail_sendername">Mike Jakowlew</b> <<a href="mailto:mjakowlew@gmail.com">mjakowlew@gmail.com</a>> wrote:
</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">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>
</blockquote></div>