Sublime directory Surf the web anonymous Pagerank Monitor


Sending email with multiple attachments

joe2movies
Wed 28 February 2007, 12:45 pm GMT +0100
HI again i used the phpmail class
Here is the code below but somehow i can't get the attachment with the email.
I created a form to select a file from a local drive but its not sending the attachment.



<?php
include_once("attach_mailer_class.php");
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form enctype="multipart/form-data" action="test.php" method="post">
  <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
  Choose a file to upload: <input name="userfile" type="file" />
 
<br><br>  <input type="submit" value="Upload File" />
</form>
<?php

print_r($_FILES);

$test = new attach_mailer("Joseph Luong", "diep@chariot.net.au", "diep@chariot.net.au", "copy@provider.com", "blind@copy.org", "Test mime email class subject");
$test->text_body = "...Some body text\n\n the admin";
$test->add_attach_file($_FILES['userfile']['name'],$encoding = "base64", $dispo = "attachment",$type=$_FILES['userfile']['tmp_name']);

$test->process_mail();
?>

</body>
</html>


olaf
Wed 28 February 2007, 12:56 pm GMT +0100
first place the php code above the html code (like in the example files)

this example you showed me is for one file...

joe2movies
Wed 28 February 2007, 01:12 pm GMT +0100
HI

yes i changed the code.  But still it is not attaching the file i upload.  if i change it to below
$test->add_attach_file($_FILES['userfile']['tmp_name']);

instead of
$test->add_attach_file($_FILES['userfile']['name']);

then it attaches but doesn't have the correct filename. 




<?php
include_once("attach_mailer_class.php");



if(isset($_FILES['userfile']['tmp_name'])){
print_r($_FILES);
$test = new attach_mailer("Joseph Luong", "diep@chariot.net.au", "diep@chariot.net.au", "copy@provider.com", "blind@copy.org", "Test mime email class subject");
$test->text_body = "...Some body text\n\n the admin";
//$test->add_attach_file($_FILES['userfile']['name'],$encoding = "base64", $dispo = "attachment",$type=$_FILES['userfile']['tmp_name']);
//$test->add_attach_file('ip2nation.zip');
$test->add_attach_file($_FILES['userfile']['name']);
$test->process_mail();
}

?>


<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form enctype="multipart/form-data" action="test.php" method="post">
  <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
  Choose a file to upload: <input name="userfile" type="file" />
 
<br><br>  <input type="submit" value="Upload File" />
</form>


</body>
</html>

joe2movies
Wed 28 February 2007, 01:39 pm GMT +0100
thanks for ur help i solved the problem.  Had to modify the function add_attach_file() a bit.
Works perfectly now even sending multiple files.


olaf
Wed 28 February 2007, 04:57 pm GMT +0100
thanks for ur help i solved the problem.  Had to modify the function add_attach_file() a bit.
Works perfectly now even sending multiple files.



thats the not the best way: never change standard classes, btw why not using the example I have provided?

Archive for SMF v1.00 by N.P. Valid XHTML 1.0 Transitional