|
 |
|
รบกวนขอตัวอย่าง jQuery lightbox อ่านไฟล์รูปจาก sql server มาเเสดงอย่างไรครับ |
|
 |
|
|
 |
 |
|
พอดีไม่เคยใช้ ไม่เป็น SQL Server เลยไม่รู้ว่า "ผมบันทึกรูปภาพ,pdf บันทึกไว้ใน sql server " เก็บทั้งไฟล์ หรือ แค่เอาชื่อไฟล์ไปเก็บ แล้วพวกไฟล์ต่าง ๆ ใส่ไว้ในโฟลเดอร์ครับ อธิบายเพิ่มเติมอีกนิด เด๋วก็มีคนช่วยครับ
|
 |
 |
 |
 |
Date :
2014-08-18 15:32:59 |
By :
apisitp |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
popup-fancybox-jquery-php-mysql
ส่วนเพิ่มเติมก็ http://fancybox.net/
ลองกำหนดแบบ iframe นะครับ 
Code (JavaScript)
$("#PDF").live('click',function(){
var pdf = $(this).attr('name');
$.fancybox({
'width' : '80%',
'height' : '100%',
'autoScale' : true,
'transitionIn' : 'fadein',
'transitionOut' : 'fadeout',
'type' : 'iframe',
'href' : 'ไฟล์ PDF'
});
});
|
 |
 |
 |
 |
Date :
2014-08-18 15:42:55 |
By :
Manussawin |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
..ได้เเล้ว ขอบคุณท่าน : gu-soft + Doctor K มากๆ ตามนี้ครับ
Code (PHP)
<!- page upload to mssql->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Uploadimage to mssql</title>
</head>
<body>
<form name="form1" method="post" action="uploadtomssql.php" enctype="multipart/form-data">
<input type="file" name="upfile"><br>
<input name="btnSubmit" type="submit" value="Submit">
</form>
</body>
</html>
<!- uploadtomssql.php ->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Uploadimage to mssql</title>
</head>
<body>
<?
if(move_uploaded_file($_FILES["upfile"]["tmp_name"],"images/".$_FILES["upfile"]["name"]))
{
$FileName = $_FILES['upfile']['tmp_name'];
$Name=$_FILES["upfile"]["name"];
$Size=$_FILES["upfile"]["size"];
$Type=$_FILES["upfile"]["type"];
/*** Insert Record */
$SQL = "INSERT INTO images ";
$SQL .="(Img_Id,Img_Name,Img_Size,Img_Type)
VALUES ( '$number_img','$Name','$Size','$Type' )";
$Query = mssql_query($SQL) or die ("error ");
}
?>
</body>
</html>
<!- view jQuery lightbox ->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
</head>
<body>
<?
$objConnect = mssql_connect("localhost","root","root") or die("Error Connect to Database");
mssql_select_db("myDatabase",$objConnect);
$strSQL = "SELECT * FROM images where Img_Id='$img_id'";
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="200" border="1">
<tr>
<th width="50"> <div align="center">Image ID </div></th>
<th width="150"> <div align="center">FilesImage</div></th>
</tr>
<?
while($objResult = mssql_fetch_array($objQuery))
{
?>
<tr>
<td><div align="center"><?=$objResult["Img_Id"];?></div></td>
<td><center>
<?
$docType=mssql_result($objQuery,$i,"Img_Type"); //หาชนิดของไฟล์
if($docType=="application/pdf") //หากเป็นไฟล์ pdf
{
echo "<div align='center'><a href='images/<?=$objResult["Img_Name"];?>' target='_blank,_top'><img src='images/attach.png'/></a></div>";
}
else //กรณีเป็น image
{
echo "<div align='center'><a href='images/$img' rel='lightbox' title='$img'><img src='images/attach.png'/></a></div>"; //*** images/ เป็น folder ที่ใช้เก็บรูปที่ upload ***//
}
</td>
</tr>
<?
}
?>
</table>
<?
mssql_close($objConnect);
?>
</body>
</html>
|
 |
 |
 |
 |
Date :
2014-08-18 17:42:33 |
By :
junior_dev |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|