简体   繁体   English

我发送附件邮件时出错警告:filesize()

[英]Getting error when i am sending attachment mail Warning: filesize()

Error: 错误:

Warning: filesize() [function.filesize]: stat failed for http://website.com/wp-content/uploads/2015/06/ddlg.jpg in /home4/moses/public_html/website.com/ipn-page-template .php on line 72 警告:在/home4/moses/public_html/website.com/ipn-page中http://website.com/wp-content/uploads/2015/06/ddlg.jpg上的 filesize()[function.filesize]:stat失败第72行的-template .php

My Code: 我的代码:

$path = 'http://website.com/wp-content/uploads/2015/06/';
    $filename = 'unnamed.jpg';
    $mailto = 'email@domain.com';
    $subject = "Thank you for Than Near";

    $file = $path . $filename;
    $file_size = filesize($file);

Filesize can allow checking the size of remote items via fopen wrappers if given a URL (as you're doing), but like many such things it's not reliable. 如果给出一个URL(正如你所做的那样), Filesize 可以允许通过fopen包装器检查远程项目的大小,但是像许多这样的东西它不可靠。 Make sure fopen wrappers are enabled, and that you can reach the item first before trying to use it. 确保启用了fopen包装器,并且在尝试使用它之前可以先到达该项目。

If you're doing this during a page load, you're also asking for it to hang if the remote host does not respond, so you should really pre-fetch images and serve them from a local file store. 如果您在页面加载期间执行此操作,那么如果远程主机没有响应,您还要求它挂起,因此您应该预先获取图像并从本地文件存储中提供它们。

Writing your own email code is never a good idea; 编写自己的电子邮件代码绝不是一个好主意; Use a library . 使用图书馆

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM