|
 |
|
สอบถาม Scrip upload files php 8.1 ครับ จากใช้งานได้ กับ upload ไฟล์ไม่ขึ้นครับ |
|
 |
|
|
 |
 |
|
สอบถามหน่อยครับ Code upload files ที่ใช้งานได้ปกติ ใน php 7.3 พอผม up php เป็น 8.1 กับ upload files ไม่ขึ้นคับCode (PHP)
<?php
if (isset($_POST['add'])) {
if ($_FILES['files']['name'] != '') {
$path = 'files/';
$file = $_FILES['files']['name'];
$file_type = strrchr($file, '.');
$time = time() . "_" . rand(1, 9999);
$pic_name = 'D-' . $time . strtoupper($file_type);
copy($_FILES['files']['tmp_name'], $path . $pic_name);
@$File_Upload1 = $pic_name;
}
$creat_at = date('Y-m-d H:i:s');
$carousel = $conn->prepare("INSERT INTO tb_modal (`img`,creat_at) VALUES (:img, :creat_at)");
$carousel->bindParam(':img', $File_Upload1);
$carousel->bindParam(':creat_at', $creat_at);
$carousel->execute();
if ($carousel->rowCount()) {
echo "<script>
setTimeout(function() {
Swal.fire({
position: 'centor',
title: 'บันทึกรายการ',
text: 'บันทึกรายการนี้แล้ว',
icon: 'success',
confirmButtonColor: '#3085d6',
timer: 5000,
showConfirmButton: true
});
},800);
</script>";
header("refresh:3; url=modal.php");
}
} elseif (isset($_POST['delete'])) {
$delete = $conn->prepare("DELETE FROM tb_modal WHERE id = :id");
$delete->bindParam(':id', $_POST['id']);
$delete->execute();
if ($delete->rowCount()) {
echo "<script>
setTimeout(function() {
Swal.fire({
position: 'top-center',
title: 'Modal Index',
text: 'คุณได้ลบรายการสำเร็จแล้ว',
icon: 'success',
confirmButtonColor: '#3085d6',
timer: 5000,
showConfirmButton: true
});
},800);
</script>";
header("refresh:3; url=modal.php");
} else {
echo "<script>
setTimeout(function() {
Swal.fire({
position: 'top-center',
title: 'Modal Index',
text: 'คุณลบรายการไม่สำเร็จ',
icon: 'warning',
confirmButtonColor: '#3085d6',
timer: 5000,
showConfirmButton: true
});
},800);
</script>";
header("refresh:3; url=carousel.php");
}
}
?>
Tag : PHP, MySQL

|
|
 |
 |
 |
 |
Date :
2024-07-15 14:57:24 |
By :
skynetcom |
View :
333 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
|
|

|
Load balance : Server 00
|