Web Application Development

Jakub Klinkovský

:: Czech Technical University in Prague
:: Faculty of Nuclear Sciences and Physical Engineering
:: Department of Software Engineering

Academic Year 2024-2025
Page 1 of 26

- [fileinput](https://docs.python.org/3/library/fileinput.html) – helper module for reading from multiple files in one `for` loop

NOTE: this approach is for some old Django version... 1. Use the `multiple` attribute for the `<input type="file">` tag. In the Django object world, this is done as follows: ```python class UploadFileForm(forms.Form): file = forms.FileField(widget=forms.ClearableFileInput( attrs={"multiple": True})) ``` 2. Process the list of files in the function in `views.py`: ```python def upload(request): ... # do something with the uploaded files for file in request.FILES.getlist("file"): save_uploaded_file(file) ... ```