Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
警告:filesize()[<;a href=';function.filesize';function.filesize<;/a>;]:C:\wamp\www\Graph\php\php.txt的stat失败_Php - Fatal编程技术网

警告:filesize()[<;a href=';function.filesize';function.filesize<;/a>;]:C:\wamp\www\Graph\php\php.txt的stat失败

警告:filesize()[<;a href=';function.filesize';function.filesize<;/a>;]:C:\wamp\www\Graph\php\php.txt的stat失败,php,Php,我正在制作一个代码,用于发送带有附件的邮件。 但是我得到了这个文件大小错误,并且还得到了以下错误: Warning: fopen(C:\wamp\www\Graph\php\php.txt) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: Warning: fread() expects parameter 1 to be resource, Warning: fclose()

我正在制作一个代码,用于发送带有附件的邮件。 但是我得到了这个文件大小错误,并且还得到了以下错误:

Warning: fopen(C:\wamp\www\Graph\php\php.txt) [<a href='function.fopen'>function.fopen</a>]: failed to open stream:

Warning: fread() expects parameter 1 to be resource,

Warning: fclose() expects parameter 1 to be resource
警告:fopen(C:\wamp\www\Graph\php\php.txt)[]:无法打开流:
警告:fread()要求参数1是资源,
警告:fclose()要求参数1为资源
我是初学者,请尝试解决我的问题。 这是我的密码:

<?php
       mail_attachment('php.txt', 'C:\\wamp\\www\\Graph\\php\\', 'saurabh.d.sharma@ericsson.com',
                           'saurabh.d.sharma@ericsson.com', 'Saurabh Sharma D', 'saurabh.d.sharma@ericsson.com',
                           'Hello Mail Send With PHP', 'Please find the attached');
                          // mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $replyto, $subject, $message);
function mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $replyto, $subject, $message) {
    ini_set('sendmail_from', 'saurabh.d.sharma@ericsson.com');
    ini_set( 'SMTP', "smtp.internal.ericsson.com" );
    $file = $path.$filename;
    $file_size = filesize($file);
    $handle = fopen($file, "r");
    $content = fread($handle, $file_size);
    fclose($handle);
    $content = chunk_split(base64_encode($content));
    $uid = md5(uniqid(time()));
    $name = basename($file);
    $header = "From: ".$from_name." <".$from_mail.">\r\n";
    $header .= "Reply-To: ".$replyto."\r\n";
    $header .= "MIME-Version: 1.0\r\n";
    $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
    $header .= "This is a multi-part message in MIME format.\r\n";
    $header .= "--".$uid."\r\n";
    $header .= "Content-type:text/plain; charset=iso-8859-1\r\n";
    $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
    $header .= $message."\r\n\r\n";
    $header .= "--".$uid."\r\n";
    $header .= "Content-Type: application/octet-stream; name=\"".$filename."\"\r\n"; // use different content types here
    $header .= "Content-Transfer-Encoding: base64\r\n";
    $header .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n";
    $header .= $content."\r\n\r\n";
    $header .= "--".$uid."--";
    if (mail($mailto, $subject, "", $header)) {
        echo "mail send ... OK"; // or use booleans here
    } else {
        echo "mail send ... ERROR!";
    }
}
?>

您的脚本无法找到(或读取)文件
C:\wamp\www\Graph\php\php.txt
您应该检查指定的文件是否可以打开:

$file = $path.$filename;
if ($handle = fopen($file, "r")) {
  $file_size = filesize($file);
  $content = fread($handle, $file_size);
  fclose($handle);
}
else {
  die("Error reading file: " . $file);
}

C:\wamp\www\Graph\php\php.txt
是否存在?可读吗?打开文件的第一个函数(
fopen()
)失败。这就是导致出现其他错误的原因。他们的文字是相当不言自明的。确保
C:\wamp\www\Graph\php\php.txt
存在并可供php.Thomas读取。我刚刚尝试打开此文件,但它显示为完全空白。我也添加了die,但在我的浏览器中再次显示空白页。非常感谢您的任何帮助。出现的问题是代码发送了一个0字节的空附件。我不知道它的确切原因,这就是为什么会发生这种情况。是的,你是对的。现在我更改了文件,现在它没有给出任何错误,但我在邮件中收到的附件是64B,完全是空白的。这是什么问题?您没有在mail()调用中包含内容。看看你的第三个论点。