|
 |
|
เราจะนำรูปเข้าไปเก็บใน 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-07-30 13:31:34 |
By :
thaicreate |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|