Откройте файл
/themes/тема/contact-form.tpl
Код:
<p class="form-group">
<label for="fileUpload">{l s='Attach File'}</label>
<input type="hidden" name="MAX_FILE_SIZE" value="2000000" />
<input type="file" name="fileUpload" id="fileUpload" class="form-control" />
</p>
замените на:
Код:
<p class="form-group">
<label for="fileUpload">{l s='Attach File'}</label>
<input type="file" name="files[]" id="fileUpload" class="form-control" />
</p>
<p class="form-group">
<label for="fileUpload">{l s='Attach File'}</label>
<input type="file" name="files[]" id="fileUpload" class="form-control" />
</p>
<input type="hidden" name="MAX_FILE_SIZE" value="2000000" />
Откройте файл
/controllers/front/ContactController.php
после:
Код:
$fileAttachment = Tools::fileAttachment('fileUpload');
добавьте:
Код:
if (isset($_FILES['files']['name']) && sizeof($_FILES['files']['name']))
{
foreach ($_FILES['files']['error'] as $key => $error)
{
if (!empty($_FILES['files']['name'][$key]) && $_FILES['files']['error'][$key] != 0)
$this->errors[] = Tools::displayError('An error occurred during the file-upload process.');
else if (!empty($_FILES['files']['name'][$key]) && !in_array(Tools::strtolower(substr($_FILES['files']['name'][$key], -4)), $extension) && !in_array( Tools::strtolower(substr($_FILES['files']['name'][$key], -5)), $extension))
$this->errors[] = Tools::displayError('Bad file extension');
}
}
после:
Код:
if (!$cm->add())
$this->errors[] = Tools::displayError('An error occurred while sending the message.');
добавьте:
Код:
if(isset($cm->id))
{
if (isset($_FILES['files']['name']) && sizeof($_FILES['files']['name']))
{
foreach ($_FILES['files']['tmp_name'] as $key => $tmp)
move_uploaded_file($tmp, _PS_UPLOAD_DIR_ . $cm->id . '__' . uniqid() . $_FILES['files']['name'][$key]);
}
}
Откройте файл
/controllers/admin/AdminCustomerThreadsController.php и перед:
Код:
$this->tpl_view_vars = array(
добавьте:
Код:
$files = array();
foreach ($messages as &$mess)
{
foreach(glob(_PS_UPLOAD_DIR_.$mess['id_customer_message'].'__*') as $file)
$mess['files'][] = _THEME_PROD_PIC_DIR_.basename($file);
}
Откройте файл
/адм.дир/themes/default/template/controllers/customer_threads/helpers/view/message.tpl и после:
Код:
{if isset($message.file_name)} <span class="message-attachment"> <i class="icon-link"></i> <a href="{$message.file_name|escape:'html':'UTF-8'}" target="_blank">{l s="Attachment"}</a></span>{/if}
добавьте:
Код:
{if isset($message.files)}
{foreach $message.files as $file}
<span class="message-attachment"> <i class="icon-link"></i> <a href="{$file|escape:'html':'UTF-8'}" target="_blank">{l s="Attachment"}</a></span>
{/foreach}
{/if}