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>