|
 |
|
PHP edit image ขอโค๊ดแก้ไขรูปหน่อยคับบบบ ช่วยหน่อยนะคับ |
|
 |
|
|
 |
 |
|
คือผมต้องการโค๊ดแก้ไขรูปภาพ โดย ลบไฟเก่าออกไปแล้วอัพเดทไฟล์ใหม่เข้าไปแทน ไฟล์ใหม่ที่อัพเดทนั้น ให้สุ่มชื่อได้ด้วย
ตัวอย่างโค๊ดตอนที่ insert เข้าไปซึ่งได้ผล
Code (PHP)
<?php
include("php-connect_db.php");
$id_place = $_POST[txt_id_place];
$name_place = $_POST[txt_name_place];
$location = $_POST[txt_location];
$officer = $_POST[txt_officer];
$ext = pathinfo(basename ($_FILES[filUpload][name]),PATHINFO_EXTENSION);
$new = 'img_'.(uniqid()).".".$ext; //สุ่มชื่อ
$image_path = "image/"; //ที่อยู่
$upload = $image_path.$new;
move_uploaded_file($_FILES[filUpload][tmp_name],$upload);
$photo = $new;
$sql = "INSERT INTO tb_place (id_place,name_place, location,officer,place_photo) VALUES
('$id_place', '$name_place', '$location', '$officer','$photo')";
mysql_db_query($db, $sql) or die ("ไม่สามารถทำงานตามคำสั่ง SQL ได้" );
Header("Location: php-admin_page2.php");
?>
ปล.ลองใช้โค๊ดจากเว็บนี้แล้วแต่มันไม่ได้ไม่รู้เหมือนกันว่าผิดตรงไหน
Tag : PHP, Appserv

|
|
 |
 |
 |
 |
Date :
2018-02-26 12:55:44 |
By :
5939011026 |
View :
2764 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
$id_place = $_GET[id];
$name_place = $_POST[txt_name_place];
$location = $_POST[txt_location];
$officer = $_POST[txt_officer];
$s= "SELECT id_place,place_photo FROM tb_place WHERE id_place = $id_place";
$rs = mysql_query($s);
$r = mysql_fetch_assoc($rs);
$delete="path/$r[place_photo]";
unlink($delete);
$ext = pathinfo(basename ($_FILES[filUpload][name]),PATHINFO_EXTENSION);
$new = 'img_'.(uniqid()).".".$ext; //สุ่มชื่อ
$image_path = "image/"; //ที่อยู่
$upload = $image_path.$new;
move_uploaded_file($_FILES[filUpload][tmp_name],$upload);
$photo = $new;
$sql = "UPDATE tb_place SET ";
$sql .= "id_place = '$id_place', ";
$sql .= "name_place = '$name_place', ";
$sql .= "location = '$location', ";
$sql .= "officer = '$officer', ";
$sql .= "place_photo = '$photo' ";
$sql .= "WHERE id_pace = $id_place";
$result = mysql_query($sql);
Header("Location: php-admin_page2.php");
|
ประวัติการแก้ไข 2018-02-26 14:07:47 2018-02-26 14:10:15 2018-02-26 14:12:27 2018-02-26 14:13:08
 |
 |
 |
 |
Date :
2018-02-26 13:39:52 |
By :
Chayut27 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|