MqTontoh Posted September 11, 2013 Share Posted September 11, 2013 I have an online form which when filled in and submitted converts into a pdf file and saves on database/server. I want to, as part of the process, attach the saved file on database and send as email.Currently am having ' failed to open stream: No such file or directory' while using phpmailer. I am not sure whether to use $_FILES function since I am not uploading a file. Any ideas or solution will help. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/282082-how-to-attach-a-file-from-database-and-send-as-email/ Share on other sites More sharing options...
jazzman1 Posted September 11, 2013 Share Posted September 11, 2013 Any ideas or solution will help. No, before to show us all related scripts! Quote Link to comment https://forums.phpfreaks.com/topic/282082-how-to-attach-a-file-from-database-and-send-as-email/#findComment-1449159 Share on other sites More sharing options...
vinny42 Posted September 12, 2013 Share Posted September 12, 2013 ' failed to open stream: No such file or directory' That error comes when the filename or the path to the file is wrong. make sure your path doesn't start with anything relative, like "../foo/bar/file.pdf" because that's the number one cause of this error. Use the complete, full path from the filesystem's root. Quote Link to comment https://forums.phpfreaks.com/topic/282082-how-to-attach-a-file-from-database-and-send-as-email/#findComment-1449197 Share on other sites More sharing options...
MqTontoh Posted September 12, 2013 Author Share Posted September 12, 2013 (edited) That error comes when the filename or the path to the file is wrong. make sure your path doesn't start with anything relative, like "../foo/bar/file.pdf" because that's the number one cause of this error. Use the complete, full path from the filesystem's root. Thank you very much Vinny42. I tried this approach and got a blank attached document and the error log indicates that the file could not be located. My concern is the method to use to pick up this file. I know this may seem amatuerish but I have tried $file="absolute_path/filename.pdf" also $file=$_FILES['']; although I think the latter may not be correct as I am not uploading from the front end. I am using PHPMailer and the line to read the file is $_FILES["my_file"]["tmp_name"]. A simple approach in geneal to go about this will be really helpful. Upoading a file from database and sending as email attachment. Thanks. Edited September 12, 2013 by MqTontoh Quote Link to comment https://forums.phpfreaks.com/topic/282082-how-to-attach-a-file-from-database-and-send-as-email/#findComment-1449251 Share on other sites More sharing options...
vinny42 Posted September 12, 2013 Share Posted September 12, 2013 $_FILES has nothing to do with it, that is *only* for uploading files using a form. "and the error log indicates that the file could not be located." So your file does not exist where you think it should exist. There's nothing I can do to help you debug that except saying that you need to check the location and the filename... Quote Link to comment https://forums.phpfreaks.com/topic/282082-how-to-attach-a-file-from-database-and-send-as-email/#findComment-1449257 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.