add_attachment in mail problem, please help ;-)
| From: | Nicolas Windpassinger - Sun | Date: | Thu, 28 Dec 2000 08:43:22 +0000 |
| Subject: | add_attachment in mail problem, please help ;-) | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-32058@lists.php.net to get a copy of this message | ||
I have a problem using mime_mail.inc that i found on the archives of
the PHP list.
I want to attach files.
Here it is:
*INTRO
-------
-the company has to buildings
-each building has its own nfs cache (ex: in building1 /home/one/tmp
will not be the same as /home/one/tmp in building 2 )
*In my Apache server:
------------------------
- i use in a html form: Attach file 1:<input type=file name="file1"
size=15>
- i then play with file1 and mime_mail.inc :
$content_type="application/octet-stream";
#i check if the file1 exists
if ($file1){
line 64 -> $fd=fopen($file1,"r");
line 65 -> $data1=fread($fd,filesize($file1));
line 66 -> fclose($fd);}
#i then send an email
$mail=new
mime_mail;
$mail->from ="TEster";
$mail->to
="nicolas.windpassinger@sun.com";
$mail->subject="testing";
$mail->body ="this is a test";
if ($file1){
$mail->add_attachment($data1,$file1,$content_type);}
$mail->send();
*in the mime_mail.inc
-------------------
function add_attachment($message, $name = "", $ctype =
"application/octet-stream") {
$this->parts[] = array (
"ctype" => $ctype,
"message" => $message,
"encode" => $encode,
"name" => $name
);
}
*Warnings i get:
------------------
-If someone uses my html form in building2 then he gets the errors:
Warning: fopen("/home/tilly/tmp/falcon.txt","r") - No such file or
directory in /space/server/apache_1.3.12/htdocs/php/Manpagetool/eng1.php
on line 64
Warning: Supplied argument is not a valid File-Handle resource in
/space/server/apache_1.3.12/htdocs/php/Manpagetool/eng1.php on line 65
Warning: Supplied argument is not a valid File-Handle resource in
/space/server/apache_1.3.12/htdocs/php/Manpagetool/eng1.php on line 66
-I think it is because php tries to get the file from the path name, and
since it will not know if the person is in building one or two, then
it will search in the default building, which is the one where he is....
is this correct ?
*What can i do??
-------------------
-Use Javascript to send the email??
Thanks in advance,
Merry xsmas, happy new year.
Nicolas.