parent id is .............. '.$parent_id;
$sql = "INSERT INTO email_attachments ";
$sql .= "(date_entered,parent_type,parent_id,data, filename, filesize, filetype) ";
$sql .= "VALUES (".$adb->formatString('email_attachments','date_entered',$date_entered).",'$parent_type','$parent_id','$data',";
$sql .= "'$filename', '$filesize', '$filetype')";
//echo '
sql is .................................... '.$sql;
$result = $adb->query($sql);
// mysql_close();
$sql2 = "select max(id) from email_attachments";
$result2 = $adb->query($sql2);
$tempRow = $adb->fetch_array($result2);
$attachmentid=$tempRow[0];
//echo '
attachment id is ' .$attachmentid;
//echo 'file name ..'.$filename;
deleteFile($uploaddir,$filename);
header("Location: index.php?action=EditView&module=$ret_module&record=$parent_id&filename=$filename&attachmentid=$attachmentid");
}
else
{
include('themes/'.$theme.'/header.php');
$errormessage = "Error Message
- Invalid file OR
- File has no data
" ;
echo $errormessage;
deleteFile($uploaddir,$filename);
include "upload.php";
}
}
/*
else
{
$errorCode = $_FILES['binFile']['error'];
if($errorCode == 4)
{
include('themes/'.$theme.'/header.php');
$errormessage = "Kindly give a valid file for upload!
" ;
echo $errormessage;
include "upload.php";
}
else if($errorCode == 2)
{
$errormessage = "Sorry, the uploaded file exceeds the maximum filesize limit. Please try a smaller file
";
include('themes/'.$theme.'/header.php');
echo $errormessage;
include "upload.php";
//echo $errorCode;
}
else if($errorCode == 3)
{
include('themes/'.$theme.'/header.php');
echo "Problems in file upload. Please try again!
";
include "upload.php";
}
}
*/
function deleteFile($dir,$filename)
{
unlink($dir.$filename);
}
?>