|
|
|
php and sql server blob ตัวอย่ากงารอัพโหลด รูปภาพลงในฐานข้อมูล sql server |
|
|
|
|
|
|
|
Code (PHP)
<?
if($_FILES["upfile"]["name"] != "Please Insert Images")
{
$FileName = $_FILES['upfile']['tmp_name'];
$Name=$_FILES["upfile"]["name"];
$Size=$_FILES["upfile"]["size"];
$Type=$_FILES["upfile"]["type"];
$DataImage = file_get_contents($FileName );
$ArrData = unpack("H*hex", $DataImage);
$HexData = "0x".$ArrData['hex'];
//*** Insert Record ***//
$Connect = mssql_connect("yourhost","user","pass") or die("Error Connect to DB");
$DB = mssql_select_db("Database");
$SQL = "INSERT INTO Images ";
$SQL .="(Img_Name,Img_Size,Img_Data,Img_Type)
VALUES ( '$Name','$Size',$HexData,'$Type' )";
$Query = mssql_query($SQL) or die ("error ");
echo "Upload Complete<br>";
echo "<a href='Img_show.php'>View_img </a> ";
}
?>
Go to : PHP SQL Server BLOB การ Upload และ Insert รูปภาพลงใน SQL Server mssql (BLOB,Image DataType)
|
|
|
|
|
Date :
2011-05-28 09:11:47 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|