Hi,
I have problems to attach files in forms. The name attribute seems to be empty although it is set.
My Code:
[[!FormIt?
&hooks=`email`
&emailTpl=`Mail`
&emailTo=`[email protected]`
&emailToName=`Kersten`
&emailFrom=`[email protected]`
&emailSubject=`New message`
]]
<p>[[+fi.error.error_message]]</p>
<form action="[[~[[*id]]]]" method="post" class="yform" enctype="multipart/form-data">
<fieldset class="columnar">
<legend>Daten</legend>
<div class="type-text">
<label>Datei</label>
<input type="file" name="mf_file" id="mf_file" size="28" value="[[+fi.mf_file]]">
</div>
</fieldset>
<div class="type-button">
<input type="reset" value="Reset" id="reset" name="reset" />
<input type="submit" value="Absenden" id="submit" name="submit" />
</div>
An email is sent. With attachment. But Outlook blocks it because the name is php****.tmp (* is a placeholder for a character or digit).
I debugged "fihooks.class.php" in the following way:
/* handle file fields */
foreach ($fields as $k => $v) {
if (is_array($v) && !empty($v['tmp_name']) && isset($v['error']) && $v['error'] == UPLOAD_ERR_OK) {
$this->modx->log(modX::LOG_LEVEL_ERROR,'[AttachDebug] '.$v['tmp_name'].' --> '.$v['name']);
$this->modx->mail->mailer->AddAttachment($v['tmp_name'],$v['name'],'base64',!empty($v['type']) ? $v['type'] : 'application/octet-stream');
}
}
The error log shows: [2010-11-04 10:55:20] (ERROR @ /modx/index.php) [AttachDebug] C:\dev\apache2214\htdocs\modx\assets\upload\php13D6.tmp -->
So the $v[’name’] is empty...
If I change
$this->modx->mail->mailer->AddAttachment($v['tmp_name'],'myfile.txt','base64',!empty($v['type']) ? $v['type'] : 'application/octet-stream');
it works...
What do I wrong? Why is $v[’name’] empty?
loxy