Created
September 22, 2021 15:57
-
-
Save akyoscommunication/599457d552e4ae6c4ec18d5666ac1fcb to your computer and use it in GitHub Desktop.
[Télécharger des fichiers pour le clients après un submit de form] #wordpress #cf7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<label><span class="form-label">Your name</span>[text* your-name]</label> | |
<label><span class="form-label">Your name</span>[email* your-email]</label> | |
<label><span class="form-label">Your name</span>[text* your-subject]</label> | |
<label><span class="form-label">Your name</span>[textarea your-message]</label> | |
<label class="not-control">[checkbox* checkbox-687 use_label_element "En cochant cette case, je reconnais avoir pris connaissance des conditions liées à l'utilisation de mes données."]</label> | |
[hidden file_dl "http://127.0.0.1:8000/app/uploads/2021/09/danseur.jpg"] | |
[hidden file_dl "http://127.0.0.1:8000/app/uploads/2021/09/logo_office_cannes.png"] | |
[submit "Submit"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class CF7Form { | |
constructor() | |
{ | |
const forms = document.querySelectorAll('form.wpcf7-form') | |
forms.forEach(f => { | |
const file_dls = f.querySelectorAll('input[type="hidden"][name="file_dl"]') | |
f.addEventListener('wpcf7mailsent', () => { | |
file_dls.forEach(fdl => { | |
this.dl(fdl.value) | |
}) | |
}) | |
}) | |
} | |
dl(uri) | |
{ | |
const link = document.createElement('a'); | |
link.download = uri.split('/').pop(); | |
link.href = uri; | |
document.body.appendChild(link); | |
link.click(); | |
document.body.removeChild(link); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment