I can successfully insert datafile in my 'datafile' table .
which is uploaded by users.
now problem is that
when echo $data
its giving me this error.
Warning: Cannot modify header information - headers already sent by (output started at c:\phpweb\phpmailattachment\mail.php:6) in c:\phpweb\phpmailattachment\mail.php on line 75
if i upload .doc file it displays it with text and junk also
please tell where am i making mistake?
Thanks
Bhoomika
this is the code.
<html>
<head>
<title> Sending attachment </title>
</head>
<body>
<?php
include("\phpweb\demo4\config\configpfinaltest.php");
include("\phpweb\demo4\config\functions.php");
// Obtain file upload vars
$fileatt = $FILES['fileatt']['tmp_name'];
$fileatt_type = $FILES['fileatt']['type'];
$fileatt_name = $_FILES['fileatt']['name'];
if (is_uploaded_file($fileatt)) {
$data = addslashes(fread(fopen($fileatt, "r"), filesize($fileatt)));
}
$connection=mysql_connect($hostname,$user,$pass) or die("Unable to connect");
$query = "insert into file set name='$from', filename='$fileatt', filetype='$fileatt_type', filenameatt='$fileatt_name' ,datafile='$data'";
$result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query. " . mysql_error());
$iid=mysql_insert_id();
//select inserted data and display it.
$query = "select * from file where id=$iid";
$result = MYSQL_QUERY($query);
$data = MYSQL_RESULT($result,0,"datafile");
$type = MYSQL_RESULT($result,0,"filetype");
Header( "Content-type: $type");
echo "Image No. $iid <br>";
echo "<br>$data";
mysql_close($connection);
?>
</body>
</html>