Jump to content

Trouble Attaching File In Email


cheezel

Recommended Posts

$ifok = true;

 

if($_FILES['attachment']['size'] > 0 && $_FILES['attachment']['size'] <= 1048576){

$fileName = $_FILES['attachment']['name'];

$tmpName = mysql_real_escape_string($_FILES['attachment']['tmp_name']);

$fileSize = $_FILES['attachment']['size'];

$fileType = $_FILES['attachment']['type'];

 

$fp = fopen($tmpName, 'r');

$content = fread($fp, filesize($tmpName));

$content = mysql_real_escape_string($content);

fclose($fp);

$fileattach = "attach_filename = '$fileName',

attach_size = '$fileSize',

attachment = '$content',

attach_type = '$fileType',";

 

}

 

if($_FILES['attachment']['size'] > 1048576){

 

$size = 1;

//$errormsg = 'File succeeded in 1MB limit';

$ifok = false;

 

}

if ($ifok){

//save to database

 

mysql_query("insert into tblmessages

 

set to_email = '" . $to . "',

to_uc = '" . $toname . "',

from_email= '" . $from . "',

from_uc = '" . $xfr_code . "',

subject = '" . $subject . "',

msgbody = '" . $message . "',

schoolid = '".$pschoolid."',

attach_filename = '".$fileName."',

attach_size = '".$fileSize."',

attachment = '".$content."',

attach_type = '".$fileType."',

 

datesent = now()")or die(mysql_error());

 

}

 

if($size == 1){

echo '<div class="error">

File exceeded in 1MB limit...

</div>';

exit;

}

 

this is my code please do help me i'm freaking out ...

Link to comment
https://forums.phpfreaks.com/topic/271665-trouble-attaching-file-in-email/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.