|
|
|
ช่วยดูโค้ดให้หน่อยค่ะทำไม resize ขนาดรูปภาพไม่ได้ค่ะ |
|
|
|
|
|
|
|
catalogue_store.php
Code (PHP)
1. ชื่อภาพ : <input type="text" name="txtName1"><br>
รูป :<input type="file" name="fileUpload1"><br>
2. ชื่อภาพ : <input type="text" name="txtName2"><br>
รูป :<input type="file" name="fileUpload2"><br>
catalogue_store2.php
Code (PHP)
$array_last=explode(".",$fileupload_name);
$c=count($array_last)-1;
$lastname=strtolower($array_last[$c]);
if($lastname=="gif" or $lastname=="jpg" or $lastname == "jpeg")
{
$images = $_FILES["fileUpload"]["tmp_name"][$i];
$new_images = "Thumbnails_".$_FILES["fileUpload"]["name"][$i];
copy($_FILES["fileUpload"]["tmp_name"][$i],"photo/".$_FILES["fileUpload"]["name"][$i]);
$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,"photo/".$new_images);
ImageDestroy($images_orig);
ImageDestroy($images_fin);
echo "Resize Successful.<br>";
//*** Insert Record ***//
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("market");
$strSQL = "INSERT INTO tblcatalogue_store";
$strSQL .="(Thumbnails,FilesName) VALUES ('".$new_images."','".$_FILES["fileUpload"]["name"][$i]."')";
$objQuery = mysql_query($strSQL);
}
else
{
echo "ไม่สำเร็จ";
}
?>
Tag : PHP, MySQL
|
ประวัติการแก้ไข 2011-06-17 20:29:42
|
|
|
|
|
Date :
2011-06-17 20:10:44 |
By :
deedee2338 |
View :
1096 |
Reply :
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
catalogue_store.php
<input type="file" name="fileUpload1">
<input type="file" name="fileUpload2">
catalogue_store2.php
for($i=0;$i<count($_FILES["fileUpload"]["name"]);$i++)
{
if(trim($_FILES["fileUpload"]["tmp_name"][$i]) != "")
{
ดูๆแล้วรู้สึกแปลกๆ ชื่อตัวแปรไม่เหมือนน่ะครับ
|
|
|
|
|
Date :
2011-06-17 20:30:47 |
By :
sakuraei |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เปลี่ยนใหม่แล้วค่ะช่วยดูหน่อยค่ะ
|
|
|
|
|
Date :
2011-06-17 20:40:47 |
By :
deedee2338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เปลี่ยนเป็นยังไงครับ เอาโค้ดมาดูกันอีกรอบ
|
|
|
|
|
Date :
2011-06-17 20:43:09 |
By :
sakuraei |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?
$fileupload = $_FILES['fileupload1']['name'];
$array_last=explode(".",$fileupload1);
$c=count($array_last)-1;
$lastname=strtolower($array_last[$c]);
if($lastname=="gif" or $lastname=="jpg" or $lastname == "jpeg")//มันไม่เข้า if นี้
{
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("market");
$strSQL = "INSERT INTO tblcatalogue_store";
$strSQL .="(name_before_photo1,before_photo1) VALUES ('".$_POST["txtName1"]."','".$_FILES["fileUpload1"]["name"]."')";
$objQuery = mysql_query($strSQL);
}
else
{
echo "ไม่สำเร็จ";
}
?>
ไม่ยอมบันทึกให้ค่ะ
|
ประวัติการแก้ไข 2011-06-17 22:25:23 2011-06-17 22:31:13 2011-06-17 22:34:36
|
|
|
|
Date :
2011-06-17 20:47:13 |
By :
deedee2338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
echo $strSQL;
$objQuery = mysql_query($strSQL);
ลองเอาค่าดู SQL Statement ครับ
|
|
|
|
|
Date :
2011-06-17 22:39:05 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ทำดูแล้ว INSERT บันทึกค่ะ แต่มันก็ยังไม่ทำ if ก่อนค่ะ
|
|
|
|
|
Date :
2011-06-17 22:45:09 |
By :
deedee2338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
$fileupload = $_FILES['fileupload1']['name']; ===> $fileupload = $_FILES['fileupload1']['tmp_name'];
$array_last=explode(".",$fileupload);
|
ประวัติการแก้ไข 2011-06-17 22:50:11 2011-06-17 22:50:39
|
|
|
|
Date :
2011-06-17 22:49:44 |
By :
sakuraei |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
$fileupload = $_FILES['fileupload1']['tmp_name'];
$array_last=explode(".",$fileupload);
$c=count($array_last)-1;
$lastname=strtolower($array_last[$c]);
if($lastname=="gif" or $lastname=="jpg" or $lastname == "jpeg")//มันไม่เข้า if นี้
{
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("market");
$strSQL = "INSERT INTO tblcatalogue_store";
$strSQL .="(name_before_photo1,before_photo1) VALUES ('".$_POST["txtName1"]."','".$_FILES["fileUpload"]["name"]."')";
$objQuery = mysql_query($strSQL);
echo $strSQL;
}
ไม่ได้
|
|
|
|
|
Date :
2011-06-17 22:54:11 |
By :
deedee2338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fileupload = $_FILES['fileupload1']['tmp_name'];
$array_last=explode(".",$fileupload);
$lastname=strtolower($array_last[1]);
ลอง echo $_FILES['fileupload1']['tmp_name']; ออกมาดูซิครับ
|
ประวัติการแก้ไข 2011-06-17 22:59:02
|
|
|
|
Date :
2011-06-17 22:57:47 |
By :
sakuraei |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
$fileupload = $_FILES['fileupload1']['tmp_name'];
$array_last=explode(".",$fileupload);
$lastname=strtolower($array_last[1]);
if($lastname=="gif" or $lastname=="jpg" or $lastname == "jpeg")//มันไม่เข้า if นี้
{
//
}
เหมือนเดิม
|
|
|
|
|
Date :
2011-06-17 22:59:59 |
By :
deedee2338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$fileupload = $_FILES['fileupload1']['tmp_name'];
$fileType = $_FILES["fileupload1"]["type"];
if($fileType=="image/gif" or $fileType=="image/jpeg" or $fileType == "image/png"){
|
|
|
|
|
Date :
2011-06-17 23:07:02 |
By :
sakuraei |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
image คือชื่อโฟรเดอร์เปล่า
ถ้าใช้ก็เมื่อเดิม
|
|
|
|
|
Date :
2011-06-17 23:10:17 |
By :
deedee2338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ฟอร์มส่งข้อมูลก่อนมาหน้านี้ ใช้ชื่อเป็น
fileupload1 และ fileupload2 หรือเปล่าครับ
|
|
|
|
|
Date :
2011-06-17 23:13:05 |
By :
sakuraei |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แบบนี้ค่ะ รูป <input type="file" name="fileupload1">
|
ประวัติการแก้ไข 2011-06-17 23:16:31
|
|
|
|
Date :
2011-06-17 23:15:13 |
By :
deedee2338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เหมือนเดิม
Code (PHP)
<form name="form1" method="post" action="catalogue_store2.php" enctype="multipart/form-data">
1. ชื่อภาพ : <input type="text" name="txtName1"><br>
รูป :<input type="file" name="fileUpload1"><br>
<input type="submit" value="ตกลง" name="ตกลง" />
</form>
Code (PHP)
<?
<?
$fileupload = $_FILES['fileUpload1']['tmp_name'];
$fileType = $_FILES["fileUpload1"]["type"];
if($fileType=="photo/gif" or $fileType=="photo/jpeg" or $fileType == "photo/png"){
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("market");
$strSQL = "INSERT INTO tblcatalogue_store";
$strSQL .="(name_before_photo1,before_photo1) VALUES ('".$_POST["txtName1"]."','".$_FILES["fileUpload"]["name"]."')";
$objQuery = mysql_query($strSQL);
echo $strSQL;
}
echo "ไม่สำเร็จ";
?>
|
|
|
|
|
Date :
2011-06-17 23:22:27 |
By :
deedee2338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$fileType=="photo/gif" or $fileType=="photo/jpeg" or $fileType == "photo/png"
ชนิดไฟล์อ่ะน่ะ มันไม่มีหรอก photo/gif photo/jpeg มันมีแต่ image/jpeg ครับ
|
|
|
|
|
Date :
2011-06-17 23:24:24 |
By :
sakuraei |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองเอาโค้ดชุดนี้ไปแปะซิครับ เอาไว้ด้านบนสุดเลย
Code (PHP)
if ($_FILES["fileUpload1"]["error"] > 0)
{
echo "Error: " . $_FILES["fileUpload1"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["fileUpload1"]["name"] . "<br />";
echo "Type: " . $_FILES["fileUpload1"]["type"] . "<br />";
echo "Size: " . ($_FILES["fileUpload1"]["size"] / 1024) . " Kb<br />";
echo "Stored in: " . $_FILES["fileUpload1"]["tmp_name"];
}
|
ประวัติการแก้ไข 2011-06-17 23:28:20
|
|
|
|
Date :
2011-06-17 23:27:26 |
By :
sakuraei |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
$fileupload = $_FILES['fileUpload1']['tmp_name'];
$fileType = $_FILES["fileUpload1"]["type"];
if($fileType=="image/gif" or $fileType=="image/jpeg" or $fileType == "image/png"){
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("market");
$strSQL = "INSERT INTO tblcatalogue_store";
$strSQL .="(name_before_photo1,before_photo1) VALUES ('".$_POST["txtName1"]."','".$_FILES["fileUpload"]["name"]."')";
$objQuery = mysql_query($strSQL);
echo $strSQL;
}
เหมือนเดิม
|
|
|
|
|
Date :
2011-06-17 23:27:30 |
By :
deedee2338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(($fileType=="image/gif") || ($fileType=="image/jpeg") || ($fileType == "image/png"))
|
|
|
|
|
Date :
2011-06-17 23:30:08 |
By :
sakuraei |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
$fileupload = $_FILES['fileUpload1']['tmp_name'];
$fileType = $_FILES["fileUpload1"]["type"];
if(($fileType=="image/gif") || ($fileType=="image/jpeg") || ($fileType == "image/png")){
echo "ss";
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("market");
$strSQL = "INSERT INTO tblcatalogue_store";
$strSQL .="(name_before_photo1,before_photo1) VALUES ('".$_POST["txtName1"]."','".$_FILES["fileUpload"]["name"]."')";
$objQuery = mysql_query($strSQL);
echo $strSQL;
}
else
{
echo "ไม่สำเร็จ";
}
ไม่ได้เหมือนเดิม
|
|
|
|
|
Date :
2011-06-17 23:34:16 |
By :
deedee2338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
if ($_FILES["fileUpload1"]["error"] > 0)
{
echo "Error: " . $_FILES["fileUpload1"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["fileUpload1"]["name"] . "<br />";
echo "Type: " . $_FILES["fileUpload1"]["type"] . "<br />";
echo "Size: " . ($_FILES["fileUpload1"]["size"] / 1024) . " Kb<br />";
echo "Stored in: " . $_FILES["fileUpload1"]["tmp_name"];
}
/*
$fileupload = $_FILES['fileUpload1']['tmp_name'];
$fileType = $_FILES["fileUpload1"]["type"];
if(($fileType=="image/gif") || ($fileType=="image/jpeg") || ($fileType == "image/png")){
echo "ss";
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("market");
$strSQL = "INSERT INTO tblcatalogue_store";
$strSQL .="(name_before_photo1,before_photo1) VALUES ('".$_POST["txtName1"]."','".$_FILES["fileUpload"]["name"]."')";
$objQuery = mysql_query($strSQL);
echo $strSQL;
}
else
{
echo "ไม่สำเร็จ";
}
*/
|
|
|
|
|
Date :
2011-06-17 23:35:26 |
By :
sakuraei |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขึ้นแบบนี้
Upload: chlid.jpg
Type: image/pjpeg
Size: 4.3876953125 Kb
Stored in: C:\Windows\Temp\php570D.tmpไม่สำเร็จ
|
|
|
|
|
Date :
2011-06-17 23:39:17 |
By :
deedee2338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
$fileupload = $_FILES['fileUpload1']['tmp_name'];
$fileType = $_FILES["fileUpload1"]["type"];
if(($fileType=="image/gif") || ($fileType=="image/jpeg") || ($fileType == "image/pjpeg")){
echo "ss";
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("market");
$strSQL = "INSERT INTO tblcatalogue_store";
$strSQL .="(name_before_photo1,before_photo1) VALUES ('".$_POST["txtName1"]."','".$_FILES["fileUpload"]["name"]."')";
$objQuery = mysql_query($strSQL);
echo $strSQL;
}
else
{
echo "ไม่สำเร็จ";
}
|
|
|
|
|
Date :
2011-06-17 23:43:24 |
By :
sakuraei |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณมาก ๆ ค่ะ ขอถามหน่อยทำไม่ต้องใส่ตัว p ด้วยค่ะ
|
|
|
|
|
Date :
2011-06-17 23:47:19 |
By :
deedee2338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มันเป็นมาตรฐานใหม่ jpeg น่ะครับ
เฮ้อ.......... ได้สักที
|
|
|
|
|
Date :
2011-06-17 23:48:40 |
By :
sakuraei |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณมากค่ะไปนอนละ
|
|
|
|
|
Date :
2011-06-17 23:49:18 |
By :
deedee2338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|