 |
|
คือเราทำเขียนโค้ดอัพโหลดรูปภาพลง DB และ Path ค่ะ รูปลง DB เรียบร้อยแล้วแต่กลับไม่ลง Path images ที่เราสร้างไว้ ช่วยทีนะคะ
Code (PHP)
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')";
Tag : PHP
|
|
 |
 |
 |
 |
Date :
2016-02-19 02:48:48 |
By :
mineymin |
View :
1543 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |