CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 PHPMailer addAttachment

Print topic Send  topic

Author Message
beefcake

Posts: 11
Posted: 06/01/2016, 9:21 AM

Hi All,

I am using php mailer to add attachment to email.

I am not able to get attachment working when I call file name from database. But works if I manually add in. For example

This works

$mail->addAttachment("CAUploads\\emailup\\201606011654390.Lighthouse.jpg");
$mail->addAttachment("CAUploads/emailup/201606011654390.Lighthouse.jpg");

This does not work

$up11 = CCDLookUp("up1", "tbl_reminders", "remind_id=".
$DBcamain->ToSQL($RecField, ccsText), $DBcamain);

$path = "CAUploads\\emailup\\".$up11;
$path1 = "CAUploads/emailup/".$up11;

$mail->addAttachment($path);
$mail->addAttachment($path1);

Any ideas why? I have printed $up11 and gives file name e.g.201606011654390.Lighthouse.jpg
View profile  Send private message
eratech


Posts: 513
Posted: 06/08/2016, 11:45 PM

@beefcake - at first glance it appears fine.

I would suggest checking the $path and $path1 is returning, not just $up11, and perhaps try single quotes instead of double quotes when concatenating them. PHP *might* by escaping something and getting the wrong file path.

See: http://php.net/manual/en/language.types.string.php

Cheers

Eric
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia
View profile  Send private message
beefcake

Posts: 11
Posted: 06/09/2016, 6:37 AM

Thanks Eric.

I worked out the code was in fact fine but the file only gets picked up from the temporary upload folder! e.g. CAUploads/tmpup.

The email code is part of a records after insert event so I would expect the file transfer from temp to live to have already occurred.

View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.