Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
404 views
in Technique[技术] by (71.8m points)

swiftmailer - PHP, Swift-mailer problem

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

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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

Try using realpath before passing the path to Swift.

$path = realpath('uploads/');


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

Just Browsing Browsing

[3] html - How to create even cell spacing within a

2.1m questions

2.1m answers

60 comments

56.9k users

...