Reputation: 13
The below code resides in our server. I want to attach file(s) from my local machine without uploading that to server. How can I do this?
$local_file_name = array('Wall.jpg'); //$_FILES['attachment']['name'];
$local_file_path = array('C:\Users\abc\Downloads\Attachment\Wall.jpg'); //$_FILES['attachment']['tmp_name'];
$size = sizeof($local_file_name);
for ($j = 0; $j < $size; $j++) {
$mail->addStringAttachment(file_get_contents($local_file_path[$j]), $local_file_name[$j]);
}
Upvotes: 0
Views: 101
Reputation: 37730
You can’t do this. Either upload the file (easy), allow your server to connect to your local machine and access files on it (much harder), host files somewhere else and provide remote access to them.
Upvotes: 1
Reputation: 1995
Sample code to add the attachment to phpMailer
$mail->addAttachment('<folder>/image.jpg', 'new.jpg');
Upvotes: 1