0

I'm trying to use mime->addAttachment() to add an attachmen to an email i'm about to send

relative path: ../../clientdata/client1/attachments/file.txt

direct path: /home/hosting/site.eu/html/ssl/clientdata/client1/attachments/file.txt

script location: /home/hosting/site.eu/html/ssl/work/php_scripts/send_email.php

send_email.php is executed using:

exec("php /home/hosting/site.eu/html/ssl/work/php_scripts/send_email.php");

Is there something I'm missing here?

The code i'm using to add the attachment:

$f = 'ssl.site.eu/clientdata/client1/attachments/file1.txt';  
$arr_file = explode('/', $f, 2);
$file_path = '/home/hosting/site.eu/html/ssl/'.$arr_file[1]; //this works
// $file_path = '../../'.$arr_file[1]; // this doesn't work;
$mime->addAttachment($file_path,'application/octet-stream');
1
  • You need to give us a bit more details on how you are trying to "find" the file with PHP. Show us the code where you are trying to "find" the file. Commented Nov 15, 2012 at 8:55

2 Answers 2

3

Beware the working directory of your process.

Now does the following code give the currect path? echo getcwd().$relative_path;

PHP getcwd()

1
  • hm, it gives the path to the file that ran the exec(). That's where the problem lies.
    – Bogdan
    Commented Nov 15, 2012 at 9:04
0

if you include some PHP files that relative the file that codes execute,you must be sure that you include these files relative the process's current directory,but not the file contains current executing codes.

Not the answer you're looking for? Browse other questions tagged or ask your own question.