when using file uploads I get strange connection resets.
The affected form contains the following element:
<input name="data_file" type="file"/>
The controller handling the file looks like this:
class FileController(BaseController):
def read_file(self):
data_file = request.POST['data_file']
return "done"
so far everything works fine.
However, as soon as I remove the line "data_file =
request.POST['data_file']" I get
- "The connection was reset(Mozilla)"
- "The page cannot be displayed (IE)"
The problem only occurs If I try to upload a File with several
megabytes in size. Smaller files work out. Also if I do not select a
file for file upload, no error occurs. Anyway, as soon as I access
uploaded files in the controller, also large files work fine. There is
nothing reported in the shell running pylons.
Thanks in advance for any hints,
/ch
from paste import fileapp
thanks for your reply.
> I would recommend using fileapp to handle file uploads.
If I got the docs right, fileapp is intended to support sending file
content from the server to the browser. My problem is related to the
other direction (a user uploads a client-local file to the server via
the browser).
/ch
Just as example this is part of my uploading controller:
def upload(self, environ):
myfile = request.POST['myfile']
fileName = myfile.filename
myfile.file.close()
On 10/12/07, Clemens Hermann <clh...@googlemail.com> wrote:
>
thanks for your sample.
> def upload(self, environ):
> myfile = request.POST['myfile']
> fileName = myfile.filename
> myfile.file.close()
What happens if you do not use the provided data? It should be
technically possible to ignore the user supplied data completely. So
the application should at least continue to work if you modify the
controller as follows:
def upload(self, environ):
#myfile = request.POST['myfile']
#fileName = myfile.filename
#myfile.file.close()
pass
The temporary file should imho be deleted automatically without
explicit close() as soon as it is no longer referenced (it is a python
tempfile).
Does your app continue if you change it as above? Continue in this
context means: Do you also get one of the following messages?
- "The connection was reset(Mozilla)"
- "The page cannot be displayed (IE)"
regards,
/ch
def upload(self, environ):
return "this is my string response"
reproduces the problem on a file upload form. As its is imho valid
controller code the error should not occur but the controller should
be stalled at/before the return statement.
regards,
/ch