update
The problem #2 (queue not getting filled from prehook) is solved by the same ugly hack in Formit2AjaxUpload.
Quote from: sapphire at Jul 16, 2015, 12:10 PMupdate
The problem #2 (queue not getting filled from prehook) is solved by the same ugly hack in Formit2AjaxUpload.
Try it with the latest version. There was an issue in the PreHook that could have stopped the execution.
[[!FormIt? &preHooks=`[[!profile]]` &hooks=`AjaxUpload2Formit,email` &ajaxuploadFieldname=`filer` &ajaxuploadTarget=`assets/uploads/tentrucks/` &ajaxuploadUid=`filer` &emailFrom=`[email protected]` &emailTpl=`myEmailChunk` &emailTo=`[[+demail]]` &emailCC=`[email protected]` &emailSubject=`Your Delivery Request Quote` &validate=`dname:required, demail:required, workmail:blank, province:required, datepicker:required, country:required, package:required, method:required, name4:required, name2:required, name1:required, name3:required, comment:required:stripTags`]]
[[!AjaxUpload? &uid=`filer` &allowedExtensions=`jpg,jpeg,png,pdf,PDF,DOC,DOCX,XLX,XLSX,doc,docx,xls,xlsx` &maxFiles=`5` &maxFilesizeMb=`12` &thumbX=`75` &thumbY=`75` ]]
However, the upload files are failing, I'm getting this message after click upload:
File_name.pdf0.1MBFailed
Should be fixed with 1.2.0-pl3.Great! The error is gone.
[[!FormIt? &preHooks=`Formit2AjaxUpload` &hooks=`AjaxUpload2Formit,email` &ajaxuploadFieldname=`attach` &ajaxuploadTarget=`files/` &ajaxuploadUid=`attach` &emailTpl=`emailChunk` &emailTo=`[email protected]` &emailSubject=`TEST` &validate=`name:required ]] <form action="[[~[[*id]]]]" method="post" class="form-inline" role="form" enctype="multipart/form-data"> <div class="input-group"> <span class="input-group-addon">Name:</span> <input required type="text" class="form-control" name="name" id="name" value="[[!+fi.name:htmlent]]"> <span>[[+fi.error.name]]</span> </div> [[!AjaxUpload? &uid=`attach` &allowedExtensions=`jpg,jpeg,png,gif` &thumbX=`75` &thumbY=`75` ]] <button type="submit" class="btn btn-large btn-success">SEND</button> </form>
AjaxUpload is not built for handling attachments.Thanks Jako, now I understand: yet another hook ;-)
<?php
$attach = $hook->getValue('attach');
//$modx->log(modX::LOG_LEVEL_ERROR,'Placeholder attachWeb: '.$attach);
if(!empty($attach)){
$attach = substr($attach, 1); //remove the first slash
$hook->modx->getService('mail', 'mail.modPHPMailer');
$hook->modx->mail->mailer->AddAttachment($attach);
}
return true;[[!AjaxUpload? &uid=`attach[]` &allowedExtensions=`jpg,jpeg,png,gif` &thumbX=`75` &thumbY=`75` ]]
<input type="file" name="attach[]" multiple="multiple">
$ajaxuploadFieldname = $modx->getOption('ajaxuploadFieldname', $scriptProperties, '');
$ajaxuploadFieldformat = $modx->getOption('ajaxuploadFieldformat', $scriptProperties, 'csv');
if ($ajaxuploadFieldname) {
$attach = $hook->getValue($ajaxuploadFieldname);
if ($ajaxuploadFieldformat == 'json') {
$attach = json_decode($attach);
} else {
$attach = explode(',', $attach);
}
…
You have use ajaxuploadTarget parameter in this hook too to get the full path for the files.
…
$hook->modx->getService('mail', 'mail.modPHPMailer');
$hook->modx->mail->mailer->AddAttachment($attach);
}