我找到了post https://stackoverflow.com/questions/3092821/php-send-e-mail-with-attachment关于向邮件添加附件。问题是如何将上传的文件与该功能连接起来?我必须通过什么?
UPD:
echo '<pre>';
print_r($_FILES);
echo '</pre>';
$uploads_dir = '/uploads'; // It has need rights
$tmp_name = $_FILES["vac_file"]["tmp_name"];
$res = is_uploaded_file($tmp_name); // This is true
$name = $_FILES["vac_file"]["name"];
move_uploaded_file($tmp_name, "$uploads_dir/$name");
echo '$tmp_name: '. $tmp_name . '; $name: ' . $name;
→
Array
(
[vac_file] => Array
(
[name] => LFS.desktop
[type] => application/octet-stream
[tmp_name] => /tmp/phpV417nF
[error] => 0
[size] => 226
)
)
yeah!
Warning: move_uploaded_file(/uploads/LFS.desktop): failed to open stream: No such file or directory in /srv/http/vacancies_attachment.php on line 47 Warning: move_uploaded_file(): Unable to move '/tmp/phpV417nF' to '/uploads/LFS.desktop' in /srv/http/vacancies_attachment.php on line 47 $tmp_name: /tmp/phpV417nF; $name: LFS.desktop
Use move_uploaded_file()
将文件移动到临时位置;将其附加到邮件中,然后将其删除(或保留它,无论您想做什么)。
See the PHP文件上传手册 http://www.php.net/manual/en/features.file-upload.post-method.php详细示例。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)