0

I Am using send grid for codeigniter. My target is send pdf mail.

An uncaught Exception was encountered

Type: Guzzle\Common\Exception\InvalidArgumentException

Message: Unable to open http://website.com/projectdemo/webusa/uploads/files/ash.pdf for reading

Filename:opt/lampp/htdocs/projectdemo/webusa/application/third_party/sendEmail/vendor/guzzle/guzzle/src/Guzzle/Http/Message/PostFile.php

Line Number: 53

My PHP Code:-

$pdfFilePath = HOSTNAME."uploads/files/ash.pdf";
 $this->sendMail($to, $subject, $message , $pdfFilePath );
Community
  • 1
  • 1
Dev Rana
  • 1
  • 4

3 Answers3

3

You can not access a file with its HTTP path. Change it to the absolute path like below

root_directory/path/to/file/residing/ash.pdf

eg(local machine): D://my_folder/myfiles/ash.pdf
eg(live server): /public_html/myfiles/ash.pdf
Arun
  • 3,640
  • 7
  • 44
  • 87
0

When trying to post a file to a remote location, Guzzle requires that file to be local. You should look into downloading the file at http://website.com/projectdemo/webusa/uploads/files/ash.pdf and then uploading it.

If you are not keen on downloading the whole file into a temporary location and then uploading it back, one possible solution would be to use streams.

Have a look at this discussion as well:

Community
  • 1
  • 1
Nikola Petkanski
  • 4,724
  • 1
  • 33
  • 41
  • The file is downloaded on this link but error at sending mail time. as well as this file also read on web page. http://website.com/projectdemo/webusa/uploads/files/ash.pdf – Dev Rana May 11 '16 at 13:02
  • The file should be local. You need to download the file at the filesystem the script runs in order to attach it to the message. – Nikola Petkanski May 17 '16 at 18:59
0

Try this

If inside application folder

$pdfFilePath = APPPATH."uploads/files/ash.pdf";

If Outside application folder

$pdfFilePath = base_url()."uploads/files/ash.pdf";
Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85