Hello all,
Before all, I want to excuse myself about the mimes mess. I’m really on the dark there. :sick:
Issue:
I’m getting one file attached, instead of two.
Request:
Can someone please lead me a hand here please?
The input fields have the same name following by ;
Here is what I think is the relevant code:
//respeitante ao upload
$allowedFileTypes = array('.JPEG','.jpeg', '.JPG','.jpg');
$maxFileSize = 1048576; //20971520 (20MB) / 2097152 (2MB) / 5242880 (5MB) / 1048576 (1MB)
$filesName = $_FILES['fotoUpload']['name']; //nome do ficheiro com extensão
$filesTempName = $_FILES['fotoUpload']['tmp_name']; //nome temporário do ficheiro
$filesType = $_FILES['fotoUpload']['type'];
//$ext = strrchr($fileName, "."); //extensão apenas
$emailID=md5(time());
/*Headers*/
$headers = 'From: Site Submission <'.$from.'>' . "\\r\
";
$headers .= "MIME-Version: 1.0\\r\
";
$headers .= "Content-Type: multipart/mixed;";
$headers .= "boundary=$emailID\\r\
--".$emailID."\\r\
";
$headers .= "Content-Type: text/html; charset=\\"UTF-8\\"\\r\
";
$headers .= "Content-Transfer-Encoding: 7bit\\r\
\\r\
".$message."\\r\
--".$emailID."\\r\
";
//anexa e aplica headers to attachment apenas se houver ficheiros. A ordem é importante.
if(!empty($filesName))
{
for($x=0;$x<count($filesName);$x++)
{
//rb stands for read binary
$tmpFile = fopen($filesTempName[$x],"rb");
$data = fread($tmpFile,filesize($filesTempName[$x]));
fclose($tmpFile);
$data = chunk_split(base64_encode($data));
$headers .= "Content-Type: {\\"application/octet-stream\\"};\
" . " name=\\"$filesName[$x]\\"\
" .
"Content-Disposition: attachment;\
" . " filename=\\"$filesName[$x]\\"\
" .
"Content-Transfer-Encoding: base64\
\
" . $data . "\
\
";
$headers .= "--{$mime_boundary}\
";
}
}
Any help plz?
Regards,
Márcio