Nice! thanks for sharing!

On Wed, Jan 25, 2012 at 6:13 PM, Omi Chiba <[email protected]> wrote:

> Solved !
>
> Please refer the slice if you're interested.
> http://www.web2pyslices.com/slices/take_slice/150
>
>
>
> On Jan 25, 9:21 am, Omi Chiba <[email protected]> wrote:
> > 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 posthttps://
> groups.google.com/group/web2py/browse_thread/thread/5e99d46f6...
> >
> > 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('[email protected]',
> >         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>
> >
> >  Email1.PNG
> > 14KViewDownload
> >
> >  Email2.PNG
> > 23KViewDownload




-- 

Bruno Rocha
[http://rochacbruno.com.br]

Reply via email to