Jump to content

SOLVED - file_exists problem


ale1981

Recommended Posts

Hi guys,

 

I am pulling my hair out here, for some reason this code is ALWAYS giving me the file not found error, even though i have checked the file destination manually and it exists! This is the part of the script giving me a headache;

 

if (!isset($dest_email) || !$dest_email) {
	$xls->send($filename);
} else {
	if (file_exists($dir . $filename)) {
		//Connect to localhost on port 25
		$swift =& new Swift(new Swift_Connection_SMTP("localhost"));
		$message =& new Swift_Message("Non Stock Sales Report");
		$message->attach(new Swift_Message_Part("The file you requested has been attached to this email."));

		//Use the Swift_File class
		$message->attach(new Swift_Message_Attachment(
			new Swift_File($dir . $filename), "$filename", "application/xls"));

		if ($swift->send($message, "$dest_email", "webserver@#####")) {
			echo 'Your email sent succesfully.';
		} else {
			echo 'ERROR - Your email was unsuccessful.';
		}
		$swift->disconnect();
		sleep(5);
		unlink($dir . $filename);
	} else {
		echo 'ERROR - '. $filename .' was not found, try again later.';
	}
}

 

Any help would be appreciated.

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/55227-solved-file_exists-problem/
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.