1
我正在嘗試使用PHP發送.CSV文件。該文件在發送之前寫入磁盤,但是當我嘗試使用file_get_contents()附加文件時;當試圖發送它創建之前創建的文件時,.CSV的結構尚未預先保存。我得到一個資源ID(#183),那麼如何將用戶可打開的文件附加爲.CSV文件?我做了一定的MIME類型和頭是正確的CSV file_get_contents發送PHP
編輯
if(!file_exists(_PS_ORDERS_DIR_.$orderDate.'/'.$file_name.'.csv'))
{
if($file = fopen (_PS_ORDERS_DIR_.$orderDate.'/'.$file_name.'.csv', 'x+'))
{
foreach ($list as $fields)
{
fputcsv($file, $fields);
}
$attachment['mime'] = 'application/vnd.ms-excel';
$attachment['content'] = file_get_contents(_PS_ORDERS_DIR_.$orderDate.'/'.$file_name.'.csv');
$attachment['name'] = $order.'order';
Mail::Send(1, 'order_conf', 'Order CSV Attachment', $success, '[email protected]', CakeToppers, NULL, NULL, $attachment);
return true;
}
我不認爲這個問題是`的file_get_contents()`。你如何添加文件併發送消息? – jeroen 2011-01-12 13:30:56