scary.png Happy Halloween! Лови жутко страшный список шаблонов и модулей со скидками.
Jump to content
Sign in to follow this  

Прикреплении файла к письму.

Recommended Posts

Добрый день. Пытался сделать прикрепление файла, но не работает, т.к. не видит инпут, вот код


<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data"  class="form-horizontal" id="popupcontact">
          <div class="form-group required">
            <label class="col-sm-2 control-label" for="input-name"><?php echo $entry_name; ?></label>
            <div class="col-sm-10">
              <input type="text" name="name" value="<?php echo $name; ?>" id="input-name" class="form-control" />
              <?php if ($error_name) { ?>
              <div class="text-danger"><?php echo $error_name; ?></div>
              <?php } ?>
          <div class="form-group required">
            <label class="col-sm-2 control-label" for="input-phone"><?php echo $entry_phone; ?></label>
            <div class="col-sm-10">
              <input type="text" name="phone" value="<?php echo $phone; ?>" id="input-phone" class="form-control" />
              <?php if ($error_phone) { ?>
              <div class="text-danger"><?php echo $error_phone; ?></div>
              <?php } ?>
          <div class="form-group required">
            <label class="col-sm-2 control-label" for="input-email"><?php echo $entry_email; ?></label>
            <div class="col-sm-10">
              <input type="text" name="email" value="<?php echo $email; ?>" id="input-email" class="form-control" />
              <?php if ($error_email) { ?>
              <div class="text-danger"><?php echo $error_email; ?></div>
              <?php } ?>
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-enquiry"><?php echo $entry_enquiry; ?></label>
            <div class="col-sm-10">
              <textarea name="enquiry" rows="10" id="input-enquiry" class="form-control"><?php echo $enquiry; ?></textarea>
          <div class="form-group">
            <label class="col-sm-3 control-label" for="input-file"><?php echo $entry_file1; ?></label>
            <div class="col-sm-9">
              <input type="file" name="file[]" value="" multiple="multiple" />
          <?php echo $captcha; ?>

и  PHP


 				$mail = new Mail();
                $mail->protocol = $this->config->get('config_mail_protocol');
                $mail->parameter = $this->config->get('config_mail_parameter');
                $mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname');
                $mail->smtp_username = $this->config->get('config_mail_smtp_username');
                $mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8');
                $mail->smtp_port = $this->config->get('config_mail_smtp_port');
                $mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout');
				$email_text = "Имя: " . html_entity_decode($this->request->post['name']) . "\n ";
				$email_text .= "Email: " . html_entity_decode($this->request->post['email']) . "\n ";
				$email_text .= "Телефон: " . html_entity_decode($this->request->post['phone']) . "\n ";
				if(!empty($this->request->post['enquiry'])) $email_text .= "Сообщение: " . html_entity_decode($this->request->post['enquiry']) . "\n";
				$files = array();

				if ($this->request->files['file']['name'] && is_array($this->request->files['file']['name'])) {
					foreach (array_keys($this->request->files['file']['name']) as $key) {
						$files[] = array(
							'name'     => $this->request->files['file']['name'][$key],
							'type'     => $this->request->files['file']['type'][$key],
							'tmp_name' => $this->request->files['file']['tmp_name'][$key],
							'error'    => $this->request->files['file']['error'][$key],
							'size'     => $this->request->files['file']['size'][$key]
				foreach($files as $file) {


Выдает ошибку с тем, что не видит инпут и не получает с него данные. Прощу помочь. Грубо говоря не видит   <input type="file" name="file[]" value="" multiple="multiple" /> вообще никак


Notice: Undefined index: file in /catalog/controller/information/popupcontact.php on line 52Array ( )


Edited by koshik

Share this post

Link to post
Share on other sites

Разобрался. Проблема в JS  - .serializeArray() не принимает файлы

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.


Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.