คือตอนนี้เขียนโค้ดให้รูปลงทั้ง Path และ DB ค่ะ แต่ตอนนี้รูปลง DB เรียบร้อยแล้ว แต่รูปกับไม่เข้า Path images ที่สร้างไว้ ควรทำยังไงดีคะ งมหาไม่เจอ
if (isset($_POST['btn-submit1'])) {
if (!empty($_FILES['pic']['name'])) {
$filename = md5($_FILES['pic']['name'].time());
$ext = explode('.', $_FILES['pic']['name']);
$dest = __DIR__.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$filename.'.'.$ext[1];
if (!copy($_FILES['pic']['tmp_name'],$dest)) {
echo "<body onload=\"window.alert('ไม่สามารถอัพโฟลดรูปภาพได้');return history.go(-1)\">";
exit();
}
$pic = $filename.'.'.$ext[1];
}
$product = $_POST['product'];
$price = $_POST['price'];
$amount = $_POST['amount'];
$id_type = $_POST['id_type'];
$id_unit = $_POST['id_unit'];
$detial = $_POST['detial'];
$sql = "INSERT INTO product (product,price,amount,id_type,id_unit,pic,detial) VALUES ('$product','$price','$amount','$id_type','$id_unit','$pic','$detial')";
สอบถามเรื่องอัพโหลดรูปลง Path ค่ะ
if (isset($_POST['btn-submit1'])) {
if (!empty($_FILES['pic']['name'])) {
$filename = md5($_FILES['pic']['name'].time());
$ext = explode('.', $_FILES['pic']['name']);
$dest = __DIR__.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$filename.'.'.$ext[1];
if (!copy($_FILES['pic']['tmp_name'],$dest)) {
echo "<body onload=\"window.alert('ไม่สามารถอัพโฟลดรูปภาพได้');return history.go(-1)\">";
exit();
}
$pic = $filename.'.'.$ext[1];
}
$product = $_POST['product'];
$price = $_POST['price'];
$amount = $_POST['amount'];
$id_type = $_POST['id_type'];
$id_unit = $_POST['id_unit'];
$detial = $_POST['detial'];
$sql = "INSERT INTO product (product,price,amount,id_type,id_unit,pic,detial) VALUES ('$product','$price','$amount','$id_type','$id_unit','$pic','$detial')";