我已经让我的脚本通过电子邮件发送一个文件,但我被要求制作以便它可以接受两个。
到目前为止,我的脚本看起来像。
// Obtain file upload vars
$fileatt = $_FILES['file1']['tmp_name'];
$fileatt_type = $_FILES['file1']['type'];
$fileatt_name = $_FILES['file1']['name'];
if (is_uploaded_file($fileatt)) {
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
$data = chunk_split(base64_encode($data));
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
}
我希望能够在头脑中使用这些并且能够通过。我曾尝试修改脚本来这样做,但我只得到一个文件。
// Obtain file upload vars
$fileatt2 = $_FILES['file2']['tmp_name'];
$fileatt_type2 = $_FILES['file1']['type'];
$fileatt_name2 = $_FILES['file1']['name'];