Hi,

Rather new to Django and using 1.2.5 and Windows, I am hung up trying
to upload a file. I get a post request with request.FILES empty.

My VIEW is:

def intro(request):
    c = {}
    c.update(csrf(request))

    if request.method == 'POST': #see if form submitted

        form = FileUploadForm(request.POST,request.FILES)
        print request.FILES
        if form.is_valid():
            text = 'You successfully uploaded file:'
            handle_uploaded_file(request.FILES['file'])
    else:
        text = 'You may upload your student data file here'
        form = FileUploadForm()

    c['form'] = form
    c['text'] = text
    return render_to_response('intro.html', c)


In SETTINGS I have:

ROOT_PATH = os.path.dirname(__file__)

MEDIA_ROOT = '/media/'

MEDIA_URL = '/media/'

And my TEMPLATE includes:

<form action="" method="post">{% csrf_token %}
    <enctype = 'multipart/form-data'></enctype>
    <css = {'all': ('/media/css/main.css',)}></css>
{{ form }}
<input type = 'submit' value = 'Upload'/>
</form>

Any suggestions much appreciated.

Bob

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to