PHP,Swift-mailer问题 [英] PHP, Swift-mailer problem

查看:100
本文介绍了PHP,Swift-mailer问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我单击联系页面上的提交"按钮,尝试提交使用swift-mailer的表单时,我得到了:

When I click submit button on my contact page, trying to submit a form that uses swift-mailer, I get this:

警告:fopen(uploads/) [function.fopen]:打开失败 流:中没有这样的文件或目录 /home/polycys2/public_html/html/swift-mailer/lib/classes/Swift/ByteStream/FileByteStream.php 在第131行

Warning: fopen(uploads/) [function.fopen]: failed to open stream: No such file or directory in /home/polycys2/public_html/html/swift-mailer/lib/classes/Swift/ByteStream/FileByteStream.php on line 131

Fatal error: Uncaught exception 'Swift_IoException' with message 'Unable to open file for reading [uploads/]' in /home/polycys2/public_html/html/swift-mailer/lib/classes/Swift/ByteStream/FileByteStream.php:133

Stack trace: 
#0 /home/polycys2/public_html/html/swift-mailer/lib/classes/Swift/ByteStream/FileByteStream.php(77): Swift_ByteStream_FileByteStream->_getReadHandle()
#1 /home/polycys2/public_html/html/swift-mailer/lib/classes/Swift/Mime/SimpleMimeEntity.php(660): Swift_ByteStream_FileByteStream->read(8192) 
#2 /home/polycys2/public_html/html/swift-mailer/lib/classes/Swift/Mime/SimpleMimeEntity.php(337): Swift_Mime_SimpleMimeEntity->_readStream(Object(Swift_ByteStream_FileByteStream)) 
#3 /home/polycys2/public_html/html/swift-mailer/lib/classes/Swift/Mime/SimpleMimeEntity.php(448): Swift_Mime_SimpleMimeEntity->getBody()
#4 /home/polycys2/public_html/html/swift-mailer/lib/classes/Swift/Mime/SimpleMimeEntity.php(463): Swift_Mime_SimpleMimeEntity->toString()
#5 /home/polycys2/public_html/html/swift-mailer/lib/classes/Swift/ in /home/polycys2/public_html/html/swift-mailer/lib/classes/Swift/ByteStream/FileByteStream.php on line 133

完整路径在服务器上存在,尽管错误消息显示'没有这样的文件或目录. 可能是什么问题呢? 谢谢大家! 圣诞快乐!

The full path exists on the server, although the error message says 'no such file or directory. What could be the problem? Thank you all in advance! And merry Christmas!

推荐答案

您需要提供uploads的完整路径而不是实际路径,因为它将被解释为相对于试图打开附件的类文件

You need to supply the full path to uploads not a realtive path because that is going to be interpreted as relative to class file that tries to open your attachment.

在将路径传递到Swift之前尝试使用realpath.

Try using realpath before passing the path to Swift.

$ path = realpath('uploads/');

$path = realpath('uploads/');

这篇关于PHP,Swift-mailer问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆