2014-01-27 85 views
0

代碼

// Attach two files: an image and a zip archive 
// - Each element contains: "file path", "file mime type" 
$attach[] = array('$image', 'image/jpeg'); 

// Calls the sendMailAtt() to send mail, outputs message if the mail was accepted for delivery or not 
if(sendMailAtt($to, $from, $subject, $message, $attach)) { 
    echo 'The mail successfully sent'; 
} 

如果你看一下$attach[]...線,array $image無法正常工作。 如果將其更改爲:image.jpg,則可以使用。但簡單的$image(通過網站上傳產生)通過郵件發送時爲0字節。

有什麼我必須改變這一行,所以它使用這個數組中生成的$圖像名稱?

+0

單引號內**變量將不會被intrepreted * * –

+0

您是否使用本地php'mail()'函數或其他庫來發送電子郵件?看看這個普通的'mail()'函數來發送附件。 http://webcheatsheet.com/php/send_email_text_html_attachment.php – Latheesan

回答

1

閱讀strings;你需要去改變它太,

$attach[] = array($image, 'image/jpeg'); 
+0

所以現在它看起來就像我想要的那樣。 但是,每個圖像只有3個字節:( – user2964588

1

如果你'那麼它不會被解釋裏面的字符串之間添加任何代碼。如果你"那麼它會被解釋之間做..這是在PHP

'"之間的差異,您應該將其添加爲

$attach[] = array($image, 'image/jpeg'); 
+0

是的,謝謝。文件名現在是正確的,但每個圖像只是3個字節:(。 – user2964588