Jump to content

Read Local File and Send Mail


ken.stendfield

Recommended Posts

I need my script to read a local file and then send it to the administrator. The sending part works perfectly, but the fopen function attempts to read the file from the server.

 

Is there anyway to make it read from your local drive? (For example. "D:\db_backup.sq'") ?

 

<?php

$handle = fopen($filename, "rb");

$contents = fread($handle, filesize($filename));

fclose($handle);


$to  = "[email protected]";
$from = "friend2gmail.com";
$headers = 'From:' . $from . "\r\n" . 'Reply-To: $from' . "\r\n" . 'X-Mailer: PHP/' . phpversion();

mail($to, $filename, $contents, $headers);

?>

Link to comment
https://forums.phpfreaks.com/topic/103193-read-local-file-and-send-mail/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.