[PHP] Problem with fopen() when php is in safe_mode

2001-11-01 Thread Daniel Bergqvist

Hi!

I'm having trouble with a script who should attach files to a mail. The script 
looks like this:
?
include inc/mime_mail.inc;
$mail = new mime_mail;
$mail - from = $email;
$mail - to = $to_email;
$mail - subject = Testing;
$mail - body = Testing;


if($dir = @opendir(/home/d5051/public_html/test)){
 while ($file = readdir($dir)) {
 $content_type = text/txt;
 if ($file != .  $file != ..){
 $fd = fopen($file,r);
 $data = fread($fd,filesize($file));
 fclose($fd);

 $mail-add_attachement($data,$file,$content_type);
 }
 }
 closedir($dir);
}
$mail-send();
?

And a get error messages like thoose below:


Warning: Unable to access testar.txt in /home/d5051/public_html/mail.php on 
line 17

Warning: fopen(testar.txt,r) - No such file or directory in 
/home/d5051/public_html/mail.php on line 17

I know that the path to the file is correct and the file is set to -rwxrwxrwx. 
Also my ISP is running php in safe_mode

Anyone who has any idea what might be wrong??

Cheers
/daniel



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Problem with fopen() when php is in safe_mode

2001-11-01 Thread Mark Roedel

 -Original Message-
 From: Daniel Bergqvist [mailto:[EMAIL PROTECTED]] 
 Sent: Thursday, November 01, 2001 9:57 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Problem with fopen() when php is in safe_mode
 
 
   if($dir = @opendir(/home/d5051/public_html/test)){

You're getting filenames from
/home/d5051/public_html/test

$fd = fopen($file,r);
 [snip]

 Warning: fopen(testar.txt,r) - No such file or directory in 
 /home/d5051/public_html/mail.php on line 17

But your script is apparently running in
/home/d5051/public_html
And trying to open the file in that same directory.

Try changing the fopen line to

$fd = fopen(test/$file,r);
Or
$fd = fopen(/home/d5051/public_html/test/$file,r);


---
Mark Roedel   | The most overlooked advantage to owning a
Systems Programmer|  computer is that if they foul up there's no
LeTourneau University |  law against whacking them around a little.
Longview, Texas, USA  |  -- Owen Porterfield 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]