Uploading multiple files

Does anyone know if you can upload multiple files in file uploader?

Put a file loader component on your form and look at its properties pane. There’s a checkbox there for allowing multiple files.

1 Like

If your file loader widget is called file_loader_1, the you can access list of uploaded files with self.file_loader_1.files. So, do something like this in the method that handles the file loader change event:

  def file_loader_1_change(self, file, **event_args):
    for fl in self.file_loader_1.files:
      app_tables.images.add_row(image=fl)

Thanks for the suggestions. What I am looking for is uploading files sequentially and there a panel showing the files uploaded and give user the option to delete or keep before submitting

If I understand what you hope to do, that’s fairly simple functionality to build - just add a repeating panel which displays each file as it gets uploaded in the ‘for’ loop. Add a button in each row of the repeating panel to optionally delete any uploaded file from the database (although I’m not clear on why you’d want to delete a file you’ve just selected to upload).

Whatever custom functionality you want to implement, you’re going to need to compose it by looping through files selected with a file loader widget. Take a look at:

1 Like

When building the template for repeating panels, what element do you suggest for displaying the file image? I tried image but it does not display on front end

This really doesn’t match your topic title “Uploading multiple files”. To draw attention to the new question, from the appropriate forum members, I suggest starting a new topic, with a new, appropriate title.

1 Like

Try this:

Clone:

https://anvil.works/build#clone:Z753QTWJQQSCI6Y6=K5QKGEOL7LLVAU66BOL7LPZG

Thanks for suggesting this example. But is there a way to show the image of the file uploaded if the file is a word document or pdf?

There are other posts in the forum discussing viewing of other types of files. e.g. for Word documents: Word Document Viewer

Thank you. I ended up settling with showing the file name using repeating panels. I think showing the word as an attachment image requires more javascript work.