Multiple files upload

51 views
Skip to first unread message

Creator

unread,
Feb 18, 2017, 3:45:11 PM2/18/17
to web2py-users
Hello everyone!
I wanna share a situation to which I can't figure a proper solution to see if I get any ideas. Sorry if this specific topic has already been covered, but I couldn't find it anywhere.

I'm trying to upload multiple files only to make some processing and return the results. At first, I don't need them saved to the upload folder, but it might come in handy later, so I'd like to have this option.
I mention this because my routine worked fine before, when I used the structure "form=FORM(TABLE" and so on. Later I changed it to "form = SQLFORM.factory(" to have the advantage of Bootstrap formatting and then ran into a double problem:
  • when uploading multiple files, I can process them and everything goes fine, but the files aren't saved to the upload folder;
  • when uploading a single file, it is saved to the upload folder, but I can't read it the same way I read with multiple files OR the same way it worked before, without using SQLFORM.factory.
I understand I could read the file from the folder, but it really doesn't make much sense to have different approaches to the same operation.

So, if there's any question so far, it would be those two:
  1. How can I upload but not save a file using the SQLFORM upload field?
  2. How can I upload multiple files and get them saved using the SQLFORM upload field?
To finish, I managed to insert the "multiple" attribute on the form created by the SQLFORM factory with this line:

form.custom.widget['files_field']['_multiple'] = ""

Thanks in advance!

Marlysson Silva

unread,
Feb 22, 2017, 8:38:10 AM2/22/17
to web2py-users
1 - You could to use the SQLFORM without io perform , here:

You can use the .validate() method in form to stop normal way processing in form , and do what you want ..

Or 

Using dbio parameter as False
Reply all
Reply to author
Forward
0 new messages