In view I use JS code, which allow using one button for opening Dialog and choosing any files. Then I send its in controller like multipart/form-data. <button id="btnTwo" class="col-sm-12 col-lg-4 good-btn" style="margin-bottom : 10px;"><div class="my-btn-conteiner"><span class="glyphicon glyphicon-paperclip"></span><p class="p-btn">Прикрепить</p> <input type="file" id="openDialog" multiple="multiple" style="display:none" /> <script> $(function() { var files; function showLoadDocsInfo(data) { console.log('In showLoadDocsInfo'); console.log(data); } $('#openDialog').on('change', function () { files = this.files; console.log('files = '+files); if (typeof files == 'undefined' ) return; var data = new FormData(); $.each( files, function( key, value ) { data.append( key, value ); }); console.log('data = '+data); jQuery.ajax({ type: "POST", url: "loadDocs", data: 'data='+JSON.stringify(data), cache: false, processData: false, contentType: false, success: showLoadDocsInfo }); }); $('#btnOne,#btnTwo,#btnThree').on('click', function() { $('#openDialog').click(); }); }); </script> My model:
db_app.define_table('doc_images', Field <http://192.168.20.184/examples/global/vars/Field>('person',label='ФИО',writable=False), Field <http://192.168.20.184/examples/global/vars/Field>('file', 'upload',label='Документ', requires=[IS_UPLOAD_FILENAME <http://192.168.20.184/examples/global/vars/IS_UPLOAD_FILENAME>(extension='^(pdf|tiff|png|bmp|jpeg|jpg)$'),IS_LENGTH <http://192.168.20.184/examples/global/vars/IS_LENGTH>(10485760, 1024)]), format = '%(title)s') What I should write in controller for adding files in db_app.doc_images? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.