|
|
|
การอัพโหลดแบบลดขนารูปครับ ทดลองบน localhost ใช้ได้แต่พออัพขึ้น server ไม่ยอม upload .ให้ |
|
|
|
|
|
|
|
โคดส่วนการอัพโหลด
Code (PHP)
<?
include("connections/conn.inc.php");
for($i=1;$i<=(int)($_POST["hdnLine"]);$i++)
{
if($_FILES["fileUpload".$i]["name"] != "")
{
$images = $_FILES["fileUpload".$i]["tmp_name"];
$new_images = "Thumbnails_".$_FILES["fileUpload".$i]["name"];
$width=325; //*** 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,"thaicreate/".$new_images);
ImageDestroy($images_orig);
ImageDestroy($images_fin);
}
{
if(trim($_FILES["fileUpload".$i]["tmp_name"],"thaicreate/".$_FILES["fileUpload".$i]["name"]))
{
$strSQL = "INSERT INTO gallery ";
$strSQL .="(date,GalleryName,Picture,aa) VALUES ('".$_POST["date".$i]."','".$_POST["txtGalleryName".$i]."','$new_images','".$_POST["aa".$i]."')";
$objQuery = mysql_query($strSQL);
echo "Copy/Upload ".$_FILES["fileUpload".$i]["name"]." completed.<br>";
}
}
}
if($objQuery)
{
echo "<script>alert('บันทึกข้อมูลเรียบร้อยแล้ว');</script>";
echo "<meta http-equiv='refresh' content='0;URL=admin_page2.php'>";
}
else
{
echo mysql_error();
}
?>
Tag : PHP
|
|
|
|
|
|
Date :
2013-01-09 22:29:10 |
By :
kooyarut |
View :
837 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Permission เปิดยังครับ 777
|
|
|
|
|
Date :
2013-01-09 23:15:36 |
By :
Krungsri |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ทำแล้วครับแต่ยังไม่ได้อยู่ดี
|
|
|
|
|
Date :
2013-01-10 13:24:29 |
By :
kooyarut |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ถ้าเขียนโคดแบบธรรมดาไม่ลดขนาดไฟล์ ยอมอัพให้
<?
session_start();
if($_SESSION['UserID'] == "")
{
echo "คุณยังไม่ได้ทำการ Log in";
echo "<meta http-equiv='refresh' content='1;URL=login.php' />";
exit();
}
if($_SESSION['Status'] != "USER")
{
echo "This page for User only!";
exit();
}
?>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874"></head>
<body>
<?
include("connections/conn.inc.php");
for($i=1;$i<=(int)($_POST["hdnLine"]);$i++)
{
if($_FILES["fileUpload".$i]["name"] != "")
{
if(copy($_FILES["fileUpload".$i]["tmp_name"],"thaicreate/".$_FILES["fileUpload".$i]["name"]))
{
$strSQL = "INSERT INTO gallery ";
$strSQL .="(date,GalleryName,Picture,aa) VALUES ('".$_POST["date".$i]."','".$_POST["txtGalleryName".$i]."','".$_FILES["fileUpload".$i]["name"]."','".$_POST["aa".$i]."')";
$objQuery = mysql_query($strSQL);
echo "Copy/Upload ".$_FILES["fileUpload".$i]["name"]." completed.<br>";
}
}
}
if($objQuery)
{
echo "<script>alert('บันทึกข้อมูลเรียบร้อยแล้ว');</script>";
echo "<meta http-equiv='refresh' content='0;URL=user_page.php'>";
}
else
{
echo mysql_error();
}
?>
</body>
</html>
|
|
|
|
|
Date :
2013-01-10 13:35:04 |
By :
kooyarut |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|