0

I am trying to give a user the chance to upload so many files he wants. So he can add more input file fields.

I did this: <input type="file" name="images[]" /> but I am stuck not knowing how to catch them serverside.

I can do images = request.POST.get('images'), but this will be an array, isnot it? how do I save them separately?

how can I catch them in server in django?

thanks a lot

doniyor
  • 31,751
  • 50
  • 146
  • 233
  • I don't think that input tag will allow you to select multiple files. See http://stackoverflow.com/questions/1175347/how-can-i-select-and-upload-multiple-files-with-html-and-php-using-http-post. – dutt Mar 11 '13 at 12:34
  • @dutt is correct. You could use a formset though. – Brandon Mar 11 '13 at 12:40

1 Answers1

1

I'm also doing that when I split the transaction by envelope so it's possible to save like that:

def view_name(request):
    if request.method == 'POST':
        images = request.POST.getlist('images[]')

        for i in range(len(images)):
            //do forloop here
catherine
  • 21,020
  • 12
  • 54
  • 75