|
|
|
นำเอา path ที่เก็บไว้ในฐานข้อมูล(รูปภาพ) มา show Thumbnails |
|
|
|
|
|
|
|
phpUploadResizeToMySQL1.html
<html>
<head>
<title>ThaiCreate.Com PHP Upload Resize to MySQL</title>
</head>
<body>
<form name="form1" method="post" action="phpUploadResizeToMySQL2.php" enctype="multipart/form-data">
<input type="file" name="fileUpload"><br>
<input name="btnSubmit" type="submit" value="Submit">
</form>
</body>
</html>
phpUploadResizeToMySQL2.php
<html>
<head>
<title>ThaiCreate.Com PHP Upload Resize to MySQL</title>
</head>
<body>
<?
if(trim($_FILES["fileUpload"]["tmp_name"]) != "")
{
$images = $_FILES["fileUpload"]["tmp_name"];
$new_images = "Thumbnails_".$_FILES["fileUpload"]["name"];
copy($_FILES["fileUpload"]["tmp_name"],"MyResize/".$_FILES["fileUpload"]["name"]);
$width=100; //*** Fix Width & Heigh (Autu caculate) ***//
$size=GetimageSize($images);
$height=round($width*$size[1]/$size[0]);
$images_orig = ImageCreateFromJPEG($images);
$photoX = ImagesX($images_orig);
$photoY = ImagesY($images_orig);
$images_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY);
ImageJPEG($images_fin,"MyResize/".$new_images);
ImageDestroy($images_orig);
ImageDestroy($images_fin);
echo "Resize Successful.<br>";
//*** Insert Record ***//
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "INSERT INTO files ";
$strSQL .="(Thumbnails,FilesName) VALUES ('".$new_images."','".$_FILES["fileUpload"]["name"]."')";
$objQuery = mysql_query($strSQL);
}
?>
<a href="phpUploadResizeToMySQL3.php">View files</a>
</body>
</html>
phpUploadResizeToMySQL2.php
<html>
<head>
<title>ThaiCreate.Com PHP Upload Resize to MySQL</title>
</head>
<body>
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM files";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="200" border="1">
<tr>
<th width="50"> <div align="center">Files ID </div></th>
<th width="150"> <div align="center">Thumbnails </div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td><div align="center"><?=$objResult["FilesID"];?></div></td>
<td><center><a href="MyResize/<?=$objResult["FilesName"];?>">
<img src="MyResize/<?=$objResult["Thumbnails"];?>" border="0"></a></center></td>
</tr>
<?
}
?>
</table>
<?
mysql_close($objConnect);
?>
<br>
<a href="phpUploadResizeToMySQL1.html">Upload Images</a>
</body>
</html>
|
|
|
|
|
Date :
2009-10-21 23:25:48 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
คือของเราเปน user pro file ค่ะ
ถ้า คนที่ยังไม่อัพโหลดให้ใช้ภาพนี้จะเขียนคำสั่งยังไงคะ
|
|
|
|
|
Date :
2010-08-14 03:24:46 |
By :
กกกก |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ถามอีกข้อนะคะ
ถ้่่า member อัพภาพมาแล้วจะเปลี่ยนภาพ ใช้คำสั่งไหนอะคะ
ชอบคุฯคะ
|
|
|
|
|
Date :
2010-08-14 04:03:47 |
By :
1234 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<?
if($array["image"]==""){
echo "<img src=\"ภาพที่ไม่ได้อัพโหลด\" >
}else{
echo "<img src=\"$array[อัพโหลดมาแล้ว]">";
}
?>
|
|
|
|
|
Date :
2010-08-14 10:25:14 |
By :
Dragons_first |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NO. 4 คำสั่ง update ครับ
|
|
|
|
|
Date :
2010-08-14 10:26:42 |
By :
Dragons_first |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ทำไมถึงอัพโหลดได้แค่เพียง Jpg ง่ะคะ
อันอื่นได้มั้ยจ้ะ ???
|
|
|
|
|
Date :
2010-08-29 13:08:34 |
By :
ขอบคุณค่ะ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tkkkkkkkkkkkkkkkkkkkkkkkkkkk
|
|
|
|
|
Date :
2011-03-05 12:38:33 |
By :
banphluang |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|