0

The full file system is the way the folders are structured in the site ?

It the directory structure of your webspace on the server. Create a file with this, put it in your main directory and open it:

<?php
  echo $_SERVER['DOCUMENT_ROOT'];
?>

That will give the full file system path to your main directory.


Matti Ressler
Suomedia

0

Could you please give me a detailed explanation and example about what you said the path must be writeable 777. Beatre i'm kind of lost when you mention that ?

0

On some web servers you can set permissions using your FTP client. In most you can right click the file or directory and chosse to set permissions. I use Filezilla and it has "file attributes" in the right click menu.

Alternatively, in your web hosting control panel you should have a file manager. Please consult the documentation for your hosting on how to set file and directory permissions.

If you are on a Windows server, I know absolutely nothing :icon_cheesygrin:


Matti Ressler
Suomedia

0

Is it possible to change the path of the attachment script to an email address so it is also sent to the same place as the rest of the text ?

0

The image(s) must be attached to the mail in the way that I showed you. Exactly where on the server the file is moved to is up to you. It actually is normally uploaded to /tmp/ and must be moved from there to a directory within your webspace. This is done with move_uploaded_file() that you see in my script.

If you are attaching mutiple images, you can use a loop rather than repeating the same code multiple times.


Matti Ressler
Suomedia

0

Okay..... So if i create a folder called upload in the server and in the path put uploader will the attached files be sent to this folder ?

0

Yes. This should work:

$path = $_SERVER['DOCUMENT_ROOT'] . '/upload/';

Matti Ressler
Suomedia

0

hope this wil help u .if not reply me
the path should be something like /home/wc.php

mail_attachment.php

<?php
function mail_attachment ($from , $to, $subject, $message, $attachment){


    $fileatt = $attachment; // Path to the file                  
    $fileatt_type = "application/octet-stream"; // File Type 
    $start=    strrpos($attachment, '/') == -1 ? strrpos($attachment, '//') : strrpos($attachment, '/')+1;
    $fileatt_name = substr($attachment, $start, strlen($attachment)); // Filename that will be used for the file as the     attachment 

    $email_from = $from; // Who the email is from 
    $email_subject =  $subject; // The Subject of the email 
    $email_txt = $message; // Message that the email has in it 
    
    $email_to = $to; // Who the email is to

    $headers = "From: ".$email_from;

    $file = fopen($fileatt,'rb'); 
    $data = fread($file,filesize($fileatt)); 
    fclose($file); 
    $msg_txt="\n\n";

    $semi_rand = md5(time()); 
    $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; 
    
    $headers .= "\nMIME-Version: 1.0\n" . 
            "Content-Type: multipart/mixed;\n" . 
            " boundary=\"{$mime_boundary}\""; 

    $email_txt .= $msg_txt;
    
    $email_message .= "This is a multi-part message in MIME format.\n\n" . 
                "--{$mime_boundary}\n" . 
                "Content-Type:text/html; charset=\"iso-8859-1\"\n" . 
               "Content-Transfer-Encoding: 7bit\n\n" . 
    $email_txt . "\n\n"; 

    $data = chunk_split(base64_encode($data)); 

    $email_message .= "--{$mime_boundary}\n" . 
                  "Content-Type: {$fileatt_type};\n" . 
                  " name=\"{$fileatt_name}\"\n" . 
                  //"Content-Disposition: attachment;\n" . 
                  //" filename=\"{$fileatt_name}\"\n" . 
                  "Content-Transfer-Encoding: base64\n\n" . 
                 $data . "\n\n" . 
                  "--{$mime_boundary}--\n"; 


    $ok = @mail($email_to, $email_subject, $email_message, $headers); 

    if($ok) { 
    } else { 
        die("Sorry but the email could not be sent. Please go back and try again!"); 
    } 
}
?>

where u want to add mail code

<?
session_start();
include "mail_attachment.php";
 ?>
$sent1 = mail_attachment("cgbasket@careerglitters.com",$too, $subject1, $body1, $attachment);
0

i have attached my php script that i need to attach files to. Could you please place that attachment script you gave me queec?

Attachments
<?php

$firstname = $_POST['FirstName'];
$lastname = $_POST['Lastname'];
$date = $_POST['Date'];
$month = $_POST['Months'];
$year = $_POST['Year'];
$Gender = $_POST['Gender'];
$country = $_POST['Country'];
$Province = $_POST['ProvinceStateRegion'];
$CityTown = $_POST['CityTown'];
$emailaddress = $_POST['EmailAddess'];
$lookingfor = $_POST['LookingFor'];
$interestedin = $_POST['InterestedIn'];
$Duration = $_POST['Duration'];
$tnc_agree = $_POST['tnc_agree'];
	
$to = "ContiAds! <datingavenue@contiads.co.za>"; // put here the email address you want this sent to
$subject = "New DatingAvenue SignUp!";
$body = "<html>".
	"<head>".
	"<title>Contact Request</title>".
	"<style type='text/css'>".
	"body,td,th {".
		"font-family: Geneva, Arial, Helvetica, sans-serif;".
		"font-size: 12px;".
	"}".
	".style1 {font-size: 24px}".
	"</style></head>".
	"<body>".
	"<p align='center' class='style1'>ContiAds New Signup</p>".
	"<table width='498' border='0' align='center' cellpadding='5' cellspacing='0'>".
	  "<tr>".
		"<td colspan='2' valign='top' bgcolor='#333333' height='2px'></td>".
	  "</tr>".
	  "<tr>".
		"<td width='104' valign='top'>Full Name:</td>".
		"<td width='374'>".$firstname." ".$lastname."</td>".
	 "</tr>".
	  "<tr>".
		"<td valign='top'>Date:</td>".
		"<td>".$date."</td>".
	  "</tr>".
	  "<tr>".
		"<td valign='top'>Month:</td>".
		"<td>".$month."</td>".
	  "</tr>".
	  "<tr>".
		"<td valign='top'>Year:</td>".
		"<td>".$year."</td>".
	  "</tr>".
	  "<tr>".
		"<td valign='top'>Gender:</td>".
		"<td>".$Gender."</td>".
	  "</tr>".
	  "<tr>".
		"<td valign='top'>Country:</td>".
		"<td>".$country."</td>".
	  "</tr>".
	  "<tr>".
		"<td valign='top'>Province:</td>".
		"<td>".$Province."</td>".
	  "</tr>".
	  "<tr>".
		"<td valign='top'>Email Address:</td>".
		"<td>".$emailaddress."</td>".
	  "</tr>".
	  "<tr>".
		"<td valign='top'>Looking For:</td>".
		"<td>".$lookingfor."</td>".
	  "</tr>".
	  "<tr>".
		"<td valign='top'>Interested In:</td>".
		"<td>".$interestedin."</td>".
	  "</tr>".
	  "<tr>".
		"<td valign='top'>Duration:</td>".
		"<td>".$Duration."</td>".
	  "</tr>".
	  "<tr>".
		"<td colspan='2' valign='top' bgcolor='#333333' height='2px'></td>".
	  "</tr>".
	"</table>".
	"</body>".
	"</html>";
	
//Always set content-type when sending HTML email
$rand = md5( time() );  
$mime_boundary = '==Multipart_Boundary_' . $rand;
$headers = "From: " . $emailaddress . "\n" .
"Reply-To:" . $emailaddress . "\n" .
"MIME-Version: 1.0\n" . 
"Content-Type: multipart/mixed; boundary=\"" . $mime_boundary . "\"";
"\n\n";	

 $message = "This is a multi-part message in MIME format.\n\n" . 
                "--" . $mime_boundary . "\n" . 
                "Content-Type: text/html; charset=\"iso-8859-1\"\n" . 
                "Content-Transfer-Encoding: 7bit\n\n" .
                $body . "\n\n";
// Add file attachment to the message 

$path = $_SERVER['DOCUMENT_ROOT']'/ezone/dating_avenue/images/';  // the path to upload images (must be writable)
$filepath = $path . basename( $_FILES['Picture']['name']);
$len = strlen($_FILES['Picture']['name']) - 4;
$extension = substr($_FILES['Picture']['name'],$len);  // get the file extension
$permitted = array('.jpg', '.JPG', '.PNG', '.png', '.GIF', '.gif');  // only allow these file extensions
$success = false;
if (in_array($extension, $permitted)) {
  if(move_uploaded_file($_FILES['Picture']['tmp_name'], $filepath)) {
    $success = true;
    $fileatt_type = 'image/' . strtoupper(ltrim($extension, '.'));
    $picture_name = $_FILES['Picture']['name'];
    $file = fopen( $filepath, 'rb' ); 
    $data = fread( $file, filesize( $filepath ) ); 
    fclose( $file );
    $data = chunk_split( base64_encode( $data ) );
    $message .= "--" . $mime_boundary . "\n" . 
             "Content-Type: \"" . $fileatt_type . "\";\n" . 
             " name=\"" . $picture_name . "\"\n" . 
             "Content-Disposition: attachment;\n" . 
             " filename=\"" . $picture_name . "\"\n" . 
             "Content-Transfer-Encoding: base64\n\n" . 
             $data . "\n\n" . 
             "--" . $mime_boundary . "--\n";            
  } else {
    $success = false;
  }
} else {
  $success = false;
}                

// end file attachment

//Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= 'From: ' . $email . "\r\n";
//$headers .= 'Cc: myboss@example.com' . "\r\n";

if (mail($to, $subject, $body, $headers)) {
?>
<script language="javascript" type="text/javascript">
	location.replace("Sign%20Up%20Success.htm");
</script>
<?php
} else {
?>
<script language="javascript" type="text/javascript">
	location.replace("Sign%20Up%20Failure.htm");
</script>
<?php
}
?>
0

Hi suomedia

I used the script that you said i should place on the path so the files are sent to server but it gives a error saying unexpected T_CONSTANT_ENCAPSED_STRING IN the php file...... What could be the problem now ?

0
<?
include "mail_attachment.php";
 ?>
$sent1 = mail_attachment("cgbasket@website.com",$too, $subject1, $body1, $attachment);

u have to include the above code in the file,juct upload the mail_attachment.
u path name should always be as /home/wesite/......start with home then the location of the file

Attachments
<?php
function mail_attachment ($from , $to, $subject, $message, $attachment){


    $fileatt = $attachment; // Path to the file                  
    $fileatt_type = "application/octet-stream"; // File Type 
    $start=    strrpos($attachment, '/') == -1 ? strrpos($attachment, '//') : strrpos($attachment, '/')+1;
    $fileatt_name = substr($attachment, $start, strlen($attachment)); // Filename that will be used for the file as the     attachment 

    $email_from = $from; // Who the email is from 
    $email_subject =  $subject; // The Subject of the email 
    $email_txt = $message; // Message that the email has in it 
    
    $email_to = $to; // Who the email is to

    $headers = "From: ".$email_from;

    $file = fopen($fileatt,'rb'); 
    $data = fread($file,filesize($fileatt)); 
    fclose($file); 
    $msg_txt="\n\nMail created using free code from 4word systems : http://4wordsystems.com";

    $semi_rand = md5(time()); 
    $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; 
    
    $headers .= "\nMIME-Version: 1.0\n" . 
            "Content-Type: multipart/mixed;\n" . 
            " boundary=\"{$mime_boundary}\""; 

    $email_txt .= $msg_txt;
    
    $email_message .= "This is a multi-part message in MIME format.\n\n" . 
                "--{$mime_boundary}\n" . 
                "Content-Type:text/html; charset=\"iso-8859-1\"\n" . 
               "Content-Transfer-Encoding: 7bit\n\n" . 
    $email_txt . "\n\n"; 

    $data = chunk_split(base64_encode($data)); 

    $email_message .= "--{$mime_boundary}\n" . 
                  "Content-Type: {$fileatt_type};\n" . 
                  " name=\"{$fileatt_name}\"\n" . 
                  //"Content-Disposition: attachment;\n" . 
                  //" filename=\"{$fileatt_name}\"\n" . 
                  "Content-Transfer-Encoding: base64\n\n" . 
                 $data . "\n\n" . 
                  "--{$mime_boundary}--\n"; 


    $ok = @mail($email_to, $email_subject, $email_message, $headers); 

    if($ok) { 
    } else { 
        die("Sorry but the email could not be sent. Please go back and try again!"); 
    } 
}
?>
0

Queenc..... Could you please insert examples on the script to show it should look when its completed because i'm not sure what to place where.... Like the uploaders form name i don't know where it goes, the path should it be to the server and so on...... I would be truly greatful if you could place examples on it

0

Hi there suomedia

I have been using your attachment script you gave but i have not been successful to this point. I have tried changing the path in ways including using the example you gave me but still no success....... Please help

0

Mr. suomedia,
I am using windows with WAMP with includes the follwing:
1. PHP 5 ...
2. MySQL ...
3. Apache2 ...

I myself interested in this issue, so I decided to know this problem too, so I did everything what you mentioned in the previous posts, and I don't see any error too. BUT the page 'SignUpFailure.html' contents.

I shall be glad if you shall have a view of the attachment ...

NOTE:
Should be mention, that I am using everything locally on my own computer, it means that I configured a 'mail server', and I can send and receive emails through PHP mail function...

0
<?
include "mail_attachment.php";
 ?>
$sent1 = mail_attachment("cgbasket@website.com",$too, $subject1, $body1, $attachment);

u have to include the above code in the file,juct upload the mail_attachment.
u path name should always be as /home/wesite/......start with home then the location of the file

Mr. queenc queenc,
I am using Windows with WAMP server ..., and I used the code you posted, I can receive the mail, also I have the attachment in my mail box, but I can not open it.
Also I see the Sorry ... PROMPT after sending the mail ...

Could you please see what is wrong ???

0

I think the only problem that you have is that you have not respected the case sensitivity of variables, eg, in your form you have the file field named as "Picture" whereas in the processing script it is "picture", eg. $_FILES

The two are NOT the same and for this reason it will never work as it is.


Matti Ressler
Suomedia

0

Thanks for replying,
I changes it to lower case, and again the same problem, mentioned in above.
could u plz test it once ???
Thanks

0

Is there an alternative php script that i can use to send files with using form ...... Somebody can you please help me !?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.