Problems, need help? Have a tip or advice? Post it here.
6 posts Page 1 of 1
Hello,

I have a form that has a file upload field which uploads to the server, then the form submits to an email address.

I realise I can't add the file as an attachment, but I'd like to provide a direct link to the attachment as part of the email confirmation.

I've experimented with the show_securefile tags and also found a secret function used in the admin when showing the file name, but I can't get it to work. Any ideas?

Code: Select all
<cms:send_mail from='******' to="*******" html='1' subject='Job Application Form Filled Out'>
                           <p><strong>Name:</strong> <cms:show frm_name /></p>
                           <p><strong>Telephone:</strong> <cms:show frm_tel /></p>
                           <p><strong>Email Address:</strong> <cms:show frm_email /></p>
                           <p><strong>Address:</strong> <cms:nl2br><cms:show frm_address /></cms:nl2br></p>
                                    <p><strong>Position:</strong> <cms:show frm_position /></p>
                           <cms:show_securefile 'frm_ulfile' >
                              <cms:dump/>
                              <cms:php>
                                 $data = "<cms:show file_id />" . '|0|0|0|0|2|0|0';
                                 $link = K_ADMIN_URL . 'download.php?auth=' . urlencode( $data . '|' . $FUNCS->hash_hmac($data, $FUNCS->hash_hmac($data, $FUNCS->get_secret_key())) );
                                 echo '<p><strong><a href="' . $link . '">Download CV</a></strong></p>';
                              </cms:php>   
                           </cms:show_securefile>
                        </cms:send_mail>
Hi,

You mentioned -
I realise I can't add the file as an attachment,

That actually is no longer the case - please see viewtopic.php?f=5&t=10750

I suggest you please try using the method given the mentioned post and let us know if you still have any problem.

Hope this helps.
Thanks, I'll take a look.

Out of interest, is the way I was attempting achievable?
Out of interest, is the way I was attempting achievable?

Yes, I think it should be achievable - I did not look deep enough into your code to find what is going wrong though as there is a better alternative available.
One thing I forgot to add is that at the same time as submitting the form, the details are also being added using db_persist_form so each of the fields are of 'bound' type - is that going to make a difference?

Code: Select all
<div>
                                <label for="name">Name</label>
                                <cms:input type="bound" name="name" class="input" placeholder="Please enter a name" required='1' "required" />
                            </div>
                            <div>
                                <label for="email">Email Address</label>
                                <cms:input type="bound" name="email" class="input" placeholder="Please enter a valid email address" required='1' validator='email' />
                            </div>
                            <div>
                                <label for="tel">Telephone</label>
                                <cms:input type="bound" name="tel" class="input" placeholder="Please enter a telephone number" required='1' "required" />
                            </div>
                            <div>
                                <label for="address">Address</label>
                                <cms:input type="bound" name="address" class="input textarea" placeholder="Address" />
                            </div>
                            <div>
                                <label for="ulfile">Upload Your CV</label>
                        <div class="file">
                           <cms:input id="ulfile" name="ulfile" type="bound" />
                        </div>
                     </div>
This is what I have now:

Code: Select all
<cms:send_mail from='*******' to="<cms:show recipient />" html='1' subject='Job Application Form Filled Out'>
   <p><strong>Name:</strong> <cms:show frm_name /></p>
   <p><strong>Telephone:</strong> <cms:show frm_tel /></p>
   <p><strong>Email Address:</strong> <cms:show frm_email /></p>
   <p><strong>Address:</strong> <cms:nl2br><cms:show frm_address /></cms:nl2br></p>
   <p><strong>Position:</strong> <cms:show frm_position /></p>
   <cms:pages masterpage=k_template_name id=k_last_insert_id show_future_entries='1'>
      <cms:show_securefile 'ulfile' >
         <cms:set my_file_link = "<cms:securefile_link file_id />" />
         <cms:attachment file=my_file_link  />
      </cms:show_securefile>
   </cms:pages>
</cms:send_mail>


I've tried the file input field with a type of 'bound' (doesn't work) and 'uploadfile' (submits the form, but no attachment in email and doesn't save to server). Not sure what I'm missing...
6 posts Page 1 of 1