PHP force me to change the count function which I changed to isset but now when I send an email it shows all the mime boundary information and the uploaded file is not encoded to base64 and appears as a string of data instead of the file name.
Here is the code block I had to change:
if(count($files) > 0){
for($i=0;$i<count($files);$i++){
if(is_file($files[$i])){
$message .= "--{$mime_boundary}n";
$fp = @fopen($files[$i],"rb");
$data = @fread($fp,filesize($files[$i]));
@fclose($fp);
$data = chunk_split(base64_encode($data));
$message .= "Content-Type: application/octet-stream; name="".basename($files[$i]).""n" .
"Content-Description: ".basename($files[$i])."n" .
"Content-Disposition: attachment;n" . " filename="".basename($files[$i]).""; size=".filesize($files[$i]).";n" .
"Content-Transfer-Encoding: base64nn" . $data . "nn";
}
}
}
This caused a fatal error in the PHP file: Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array,……
I changed it to this:
if(isset($files)){
for($i=0;$i<count($files);$i++){
if(is_file($files[$i])){
$message .= "--{$mime_boundary}n";
$fp = @fopen($files[$i],"rb");
$data = @fread($fp,filesize($files[$i]));
@fclose($fp);
$data = chunk_split(base64_encode($data));
$message .= "Content-Type: application/octet-stream; name="".basename($files[$i]).""n" .
"Content-Description: ".basename($files[$i])."n" .
"Content-Disposition: attachment;n" . " filename="".basename($files[$i]).""; size=".filesize($files[$i]).";n" .
"Content-Transfer-Encoding: base64nn" . $data . "nn";
}
}
}
The file is uploaded to the correct path statement so it’s working from that standpoint but when the confirmation email is sent I get this:
–==Multipart_Boundary_xe5853c74b9fb3bc6378b9c0706e7e587x
Content-Type: text/html; charset=”UTF-8″
Content-Transfer-Encoding: 7bit
Thank you No Name for the print quote or order. You will receive another email with your prices or if a quote was not required an email updating the status and delivery date. If you have any questions email [email protected] or call Somebody (xxx)xxx-xxxx”
–==Multipart_Boundary_xe5853c74b9fb3bc6378b9c0706e7e587x–
And the form itself sends this message:
Content-Type: text/html; charset=”UTF-8″
Content-Transfer-Encoding: 7bit
Customer
Date: 04/25/2024
Ordered By: Bob Morgan
Department: test
Phone: 5044588548
Email: [email protected]
Expense Code: 75900
Cost Code:000000/75900
Cost Code not Listed:test
Needed By: 05/08/2024
Mail Drop: Plaza
Print Specs
Quantity: 100
Print type: color
Item: test.pdf
Size: 5.5×8.5
Paper size: 70#offset
Fold: halffold
Second Print Specs
–==Multipart_Boundary_xe5853c74b9fb3bc6378b9c0706e7e587x
Content-Type: application/octet-stream; name=”Screenshot 2024-03-04 174848.png”
Content-Description: Screenshot 2024-03-04 174848.png
Content-Disposition: attachment;
filename=”Screenshot 2024-03-04 174848.png”; size=231147;
Content-Transfer-Encoding: base64
iVBORw0KGgoAAAANSUhEUgAABYMAAAK0CAYAAABRKiIYAAAAAXNSR0IArs4c6QAAAARnQU1BAACx
jwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABjaVRYdFNuaXBNZXRhZGF0YQAAAAAAeyJjbGlw
UG9pbnRzIjpbey……
This worked before the new version caused me to change the file.
What can I do to correct the emails so that the html data and the encoding don’t appear on the emails. Thanks much!