|
|
|
จะเอารูปเก็บลง DB MSSQL ด้วย PHP ยังไงครับ คือผมเคยทำแต่ใช้ PHP เก็บ MySQL DATA TYPE เป็น BLOB ทีนี้มาเจอ MSSQL มึน |
|
|
|
|
|
|
|
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<body>
<?
if($_FILES["filUpload"]["name"] != "")
{
//*** Insert Record ***//
$objConnect = mssql_connect("localhost","sa","") or die("Error Connect to Database");
$objDB = mssql_select_db("mydatabase");
$strSQL = "INSERT INTO files ";
$strSQL .=" ( Name, FilesType,FilesName) ";
$strSQL .=" SELECT '".$_POST["txtName"]."','".$_FILES["filUpload"]["type"]."', ";
$strSQL .=" BulkColumn FROM OPENROWSET( ";
$strSQL .=" Bulk '".$_FILES["filUpload"]["tmp_name"]."', SINGLE_BLOB) AS BLOB ";
$objQuery = mssql_query($strSQL);
echo "Copy/Upload Complete<br>";
mssql_close($objConnect);
}
?>
<a href="PageUploadToSQLServer3.php">View files</a>
</body>
</html>
Go to : PHP Upload File BLOB/Image to SQL Server Database (mssql-OPENROWSET)
|
|
|
|
|
Date :
2011-08-01 20:41:34 |
By :
thaicreate |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|