|
 |
|
upload รูป ไม่เข้า โฟเดอรอะครับ ผมทำการอัฟโหลดแล้วย่อรูป แล้ว copy แต่ไม่ยอมเข้าโฟเดอรอ่ะครับ |
|
 |
|
|
 |
 |
|
ผมทำการอัฟโหลดแล้วย่อรูป แล้ว copy แต่ไม่ยอมเข้าโฟเดอรอ่ะครับ
Code (PHP)
if($_FILES['fileupload']['tmp_name'] != "") { //เช็คว่ามีการอัปรูป
copy ($_FILES['fileupload']['tmp_name'], $_FILES['fileupload']['name']); //ทำการ copy รูป
$images = $_FILES['fileupload']['name'];
$height = 400; //กำหนดขนาดความสูง
$size = getimagesize($images);
$width = round($height*$size[0]/$size[1]); //ขนาดความกว้่างคำนวนเพื่อความสมส่วนของรูป
if($size[2] == 1) {
$images_orig = imagecreatefromgif($images); //resize รูปประเภท GIF
} else if($size[2] == 2) {
$images_orig = imagecreatefromjpeg($images); //resize รูปประเภท JPEG
}
$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, $images); //ชื่อไฟล์ใหม่
imagedestroy($images_orig);
imagedestroy($images_fin);
$path="photo";
copy( $images ,"../$path/$images");
}
คือตอนนี้มัน copy รูปไว้ 2 ที่อ่ะครับ
อยากไว้ใน /photo ที่เดียวอ่ะ
แก้ยังไงครับ
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2009-10-14 17:22:57 |
By :
vespaclassic |
View :
1046 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
include("connect.php");
if(empty($Pisbn) || empty($Pname) || empty($Pdetail) || empty($Pprice) )
{
echo "<script>alert('กรุณากรอกข้อมูลให้ครบครับ !!!');history.back();</script>";
exit();
}
$image = $_FILES['image'];
$imageinfo = pathinfo($image['name']);
$Ppricemember = $Pprice*0.95;
if($image['size']!=0 && $imageinfo['extension']!='jpg' && $imageinfo['extension']!='gif')
{
echo "<script>alert('แนบไฟล์ .gif หรือ .jpg เท่านั้น');history.back();</script>";
exit();
}
$sql = "INSERT INTO product VALUES('','$Pisbn','$Pname','$Pdetail','$Pprice','$Ppricemember','$Pqty','$Cateid')";
mysql_query($sql)or die("ERROR=$sql");
if($image['size']!=0)
{
$imagename = mysql_insert_id().".gif";
move_uploaded_file($image['tmp_name'],"images/product/$imagename");
}
mysql_close($conn);
echo "<script>alert('เพิ่มช้อมูลสินค้าเรียบร้อยแล้ว');window.location='product_add.php';</script>";
ลองดู code เพิ่มสินค้าของผมครับ มันจะอัพรูปไปเก็บไว้ใน folder images/photo
|
 |
 |
 |
 |
Date :
2009-10-14 17:33:37 |
By :
CMD |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แล้วของผมจะแก้โค๊ดยังไงอะครับ
|
 |
 |
 |
 |
Date :
2009-10-14 18:09:07 |
By :
vespaclassic |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เปลี่ยนตรงนี้ครับ
copy ($_FILES['fileupload']['tmp_name'],"ชื่อโฟลเดอร์/" $_FILES['fileupload']['name']); //ทำการ copy รูป
|
 |
 |
 |
 |
Date :
2009-10-15 11:47:47 |
By :
Dragons_first |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|