Simon,Thank you for your help.
I changed  the view a little. I have

############
def UploadFile(request):
        if request.POST:
                print "We are in POST"
                import os.path
                filepath = '/Media/Static/'
                filename = request.FILES[ 'file' ][ 'filename' ]
                filetype = request.FILES[ 'file' ][ 'content-type' ]
                data = request.FILES[ 'file' ][ 'content' ]
                fullfilepath = os.path.join( filepath, filename )
                fullfilepath = os.path.normpath( fullfilepath )
                fullfilepath = os.path.normcase( fullfilepath )
                f = open( fullfilepath, 'wb' )
                f.write( data )
                f.close( )
                print "SUCCESS"
                return HttpResponse("SUCCESS")
        else:
                print "We are in GET "
                errors = new_data = {}
                manipulator = users.AddManipulator()
                form = formfields.FormWrapper(manipulator, new_data, errors)
                t = template_loader.get_template("board/UploadFile")
                c = Context(request, {'form': form})
                return HttpResponse(t.render(c))
#################

and the  form like this:

#############
<form action="." method="post" enctype="multipart/form-data">
  <p>Choose a file to be loaded: <input type="file" name="file"
id="file"> <input
  type="submit" value="Upload File"> </p>
</form>
#############

but now the problem is that the program will never go to request.POST
section.
But when I remove  enctype="multipart/form-data" from the form, the
program will go to request.POST  section but I will receive the error:
##############
Request Method: POST
Request URL: http://localhost:8082/Up/
Exception Type: MultiValueDictKeyError
Exception Value: "Key 'file' not found in MultiValueDict {}"
Exception Location:
C:\PYTHON23\lib\site-packages\django\utils\datastructures.py in
__getitem__, line 73
#######

and the problem is with
filename = request.FILES[ 'file' ][ 'filename' ]  ...

But why? Thank you for the reply
Regards,
L.

Reply via email to