0
그래서 사용자가 데이터를 수집하고 일부는 .csv 파일에 넣은 다음 사용자에게 첨부 파일로 보낸 양식에 데이터를 입력 한 후이 PHP 스크립트를 사용합니다. 첨부 파일하지만 .csv 파일로 보낼 수있는 이메일을 얻을 수 있습니다 항상 비어 있고 난내 CSV 파일이 비어있는 이유는 무엇입니까
function send_csv_mail($csvData, $body, $to, $subject, $from)
{
$multipartSep = '-----' . md5(time()) . '-----';
$headers = [
"From: $from",
"Reply-To: $from",
"Content-Type: multipart/mixed; boundary=\"$multipartSep\"",
];
$fp = fopen('php://temp', 'w');
fputcsv($fp, ["Supplier Number", "Supplier Name", "Product Code", "Product Description", "Unit of Measure", "Product Group", "Buy Price EX GST"]);
$testData = [
['123', '456', '789', '012', '345', '678', '901'],
['abc', 'def', 'ghi', '123', '456', '789', '012'],
['jkl', 'mno', 'pqr', '123', '456', '789', '012'],
];
foreach ($testData as $data) {
fputcsv($fp, $data);
}
fclose($fp);
$attachment = chunk_split(base64_encode(file_get_contents($fp)));
$newBody = "--$multipartSep\r\n"
. "Content-Type: text/html; charset=ISO-8859" . "\r\n"
. "\r\n"
. "$body" . "\r\n"
. "--$multipartSep" . "\r\n"
. "Content-Type: text/csv" . "\r\n"
. "Content-Transfer-Encoding: base64" . "\r\n"
. "Content-Disposition: attachment; filename=\"New_Parts_and_Barcodes_Request.csv\"" . "\r\n"
. "\r\n"
. "$attachment" . "\r\n"
. "--$multipartSep--";
return @mail($to, $subject, $newBody, implode("\r\n", $headers));
}
내 서식 첫 번째 게시물 : 미안
여전히 – Dath
당신이 FCLOSE ($ FP)'이동하려고 수있는 다른 아이디어를 통해 데이터 못하고,받는 사람을' 스크립트 끝? –
fclose ($ fp)가 스크립트가 끝나기 직전으로 이동되었습니다. 나는 그것을 다시 시도했지만 여전히 주사위를 사용하지 않았다. – Dath