Hi and happy new year to all !!
i have a php script intended to upload image file from browser to sql server.. which is like this
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
if($POST)
{
if(!is_array($FILES) || !is_array($FILES['visitor_photo']))
{
die("no file was uploaded");
}
$tmp = $FILES['visitor_photo']['tmp_name'];
$fp = fopen($tmp, 'rb');
$image = fread($fp, filesize($tmp));
fclose($fp);
$name = $_POST['visitor_name'];
$db = @mysql_connect("xxxxxxxxxx", "xxxxxxxxx", "xxxxxxxx") or die (mysql_error());
@mysql_select_db("hit_song", $db) or die (mysql_error());
// gzip file
//$image = gzdeflate($image, 9);
$image = mysql_real_escape_string($image, $db);
$result = @("INSERT INTO tb_member (nom, photo) VALUES ('$name' ,'$image')", $db);
if($result === false)
{
die("could not insert into database");
}
unlink($tmp);
exit("upload successful");
}
?>
<form action="" method="post" enctype="multipart/form-data" name="fjoindre" id="fjoindre">
Name:
<input type="text" name="visitor_name">
Image:
<input name="visitor_photo" type="file" id="visitor_photo">
<input type="submit" value="Send" name="Submit">
</form>
</body>
</html>
Also i have the table with 2 rows { photo longtext no null} and { Nom varchar no null}
On submit i got the nom filed correctly but in the photo filed it shows some text in unrecognized format....
My question .... am i successful in uploading the foto? If the photo was uploaded to anywhere ( DB or file directory ) how to retrieve it correctly?
Should i modify the above php script ?
Please help me . Thanks in Advance