I was creating a simple app which will send email with a single document and it works fine. I found Paolo's post to handle multiple documents and tried. It worked great but I have two problems.
Paolo's post https://groups.google.com/group/web2py/browse_thread/thread/5e99d46f6fcc6917/47e7723396647f2b?lnk=gst&q=multiple+upload#47e7723396647f2b Problem 1. Upload files are not saved under the app directories 2. And how can I retrieve the new file names (I could use "form.vars.attachment_newfilename" for a single document but not sure If I can use it for multiple documents) Controller ============== def index(): import os filepath = os.path.join(request.folder,'uploads') form=SQLFORM.factory(Field('subject',requires=IS_NOT_EMPTY()), Field('message','text',requires=IS_NOT_EMPTY()), Field('attachment','upload',uploadfolder=filepath) ) if form.accepts(request): counter = 0 text = "" for var in request.vars: if var.startswith('attachment') and request.vars[var] != '': counter += 1 text += " " + request.vars[var].filename response.flash = str(counter) + text # Send Email """ mail.send('och...@xxx.com', request.vars.subject, request.vars.messagei attachments = [Mail.Attachment(filepath + '/' + form.vars.attachment_newfilename, filename=request.vars.attachment.filename)] ) """ return dict(form=form) View ============= {{response.files.extend([URL('static','css/multiupload.css'),URL('static','js/jquery.multiupload.js')])}} {{left_sidebar_enabled,right_sidebar_enabled=False,False}} {{extend 'layout.html'}} <h3>Send Mail</h3> <div> {{=form}} {{=BEAUTIFY(request.vars)}} <script type="text/javascript" charset="utf-8"> //<!-- jQuery('input[name="attachment"]:not(.processed)').multiUpload({ mw_placeholder:"{{=T('insert a title')}}", mw_text_addBtn:"+", mw_tooltip_addBtn:"{{=T('add a file')}}", mw_text_clearBtn:"x", mw_tooltip_clearBtn:"{{=T('remove all')}}", mw_tooltip_removeFileBtn:"{{=T('remove this file')}}", mw_tooltip_removeGroupBtn:"{{=T('remove this file group')}}", mw_group_title:"{{=T('FILE GROUP')}}", mw_fileNumber:false, mw_maxElementAllowed:5 }); //--> </script> </div>
<<attachment: Email1.PNG>>
<<attachment: Email2.PNG>>