Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
File 如何使用cakephp 2.x上传文件并将其附加到电子邮件?_File_Email_Cakephp_Upload_Attachment - Fatal编程技术网

File 如何使用cakephp 2.x上传文件并将其附加到电子邮件?

File 如何使用cakephp 2.x上传文件并将其附加到电子邮件?,file,email,cakephp,upload,attachment,File,Email,Cakephp,Upload,Attachment,我是cakephp 2.x的新手。 我想为用户建立一个简单的表单来上传他们的简历文件,然后将其作为电子邮件附件发送。 不知何故,我找不到一种方法将上传的文件附加到电子邮件。欢迎任何帮助! 这是我的send.ctp: <?php echo $this -> Form -> create(null, array('enctype' =>'multipart/form-data')); echo $this -> Form -> input('firs

我是cakephp 2.x的新手。 我想为用户建立一个简单的表单来上传他们的简历文件,然后将其作为电子邮件附件发送。 不知何故,我找不到一种方法将上传的文件附加到电子邮件。欢迎任何帮助! 这是我的send.ctp:

<?php 
   echo $this -> Form -> create(null, array('enctype' =>'multipart/form-data'));
   echo $this -> Form -> input('first_name', array('type'=>'text')); 
   echo $this -> Form ->input('last_name', array('type'=>'text'));
   echo $this -> Form ->input('contact_number',array('type'=>'text')); 
   echo $this -> Form ->input('email',array('type'=>'text'));
   echo $this -> Form ->input('resume', array('type' => 'file',));
   echo $this -> Form ->end('Submit');      
?>
}$this->data['resume']是一个数组,包含有关文件上载的信息

该阵列的外观如下所示:

array(
   'name' => '(filename)',
   'type' => '(filetype)',
   'tmp_name' => '(file location)',
   'error' => (int) 0,
   'size' => (int) 1
)
尝试使用以下方法设置附件:

$email->attachments(array($this->data['resume']['name'] => $this->data['resume']['tmp_name']));
$this->data['resume']是一个数组,包含有关文件上载的信息

该阵列的外观如下所示:

array(
   'name' => '(filename)',
   'type' => '(filetype)',
   'tmp_name' => '(file location)',
   'error' => (int) 0,
   'size' => (int) 1
)
尝试使用以下方法设置附件:

$email->attachments(array($this->data['resume']['name'] => $this->data['resume']['tmp_name']));

我附上了我的email.php,以防这是因为电子邮件服务器的问题。其他字段,如姓名、联系人号码都正确发送,没有附件。我的错,我的gmail有附件问题。我刚刚使用了另一个gmail帐户,它工作正常!谢谢我附上了我的email.php,以防这是因为电子邮件服务器的问题。其他字段,如姓名、联系人号码都正确发送,没有附件。我的错,我的gmail有附件问题。我刚刚使用了另一个gmail帐户,它工作正常!谢谢虽然这个答案可能是正确的,但解释为什么这个答案可能是正确的是有用的。虽然这个答案可能是正确的,但解释为什么这个答案可能是正确的是有用的。
$Path = WWW_ROOT."img";
$fileName = 'image.png';    
$this->Email->to = $to;
$this->Email->subject = $subject;
$this->Email->attachments = array($Path.$fileName);
$this->Email->from = $from;