Dev Rana
Dev Rana

Reputation: 1

File permission error on server

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 );

Upvotes: 0

Views: 157

Answers (3)

Abdulla Nilam
Abdulla Nilam

Reputation: 38609

Try this

If inside application folder

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

If Outside application folder

$pdfFilePath = base_url()."uploads/files/ash.pdf";

Upvotes: 0

Nikola Petkanski
Nikola Petkanski

Reputation: 4794

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:

Upvotes: 0

Arun
Arun

Reputation: 3721

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

Upvotes: 3

Related Questions