สอบเรื่องการ del file ค่ะ
ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา สอบเรื่องการ del file ค่ะ
สอบเรื่องการ del file ค่ะ
Copy
ถ้าต้องการลบไฟล์ต้องทำยังไงค่ะ หาโค้ดมากหลายวันแล้วค่ะ ช่วยดูให้หน่อยได้ไหมค่ะ ว่าต้องใส่ del ตรงไหนค่ะ
<?php
header("Content-type:application/json; charset=UTF-8");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
include("Connections/connect.php");
$crews=$_GET["id"];
$sqlq ="select cp_id from crew_personals where cp_id = '".$crews."' ";
$resultq = mysql_query($sqlq);
$rowq = mysql_fetch_array($resultq);
if (empty($_FILES['file_upload_1'])) {
echo json_encode("['error'=>'No files found for upload.']");
// or you can throw an exception
return; // terminate
}
// get the files posted
$images = $_FILES['file_upload_1'];
// a flag to see if everything is ok
$success = null;
// file paths to store
$paths = null;
// get file names
$filenames = $images['name'];
// loop and process files
for($i=0; $i < count($filenames); $i++){
$ext = explode('.', basename($filenames[$i]));
$target = "document/" .$filenames[$i];
if(move_uploaded_file($images['tmp_name'][$i], $target)) {
$success = true;
$paths[] = $target;
} else {
$success = false;
$sql = "DELETE FROM crew_documents where cd_fk_nd_id='1' and cd_fk_cp_id = '".$crews."'";
unlink("document/".$row['file']);
$result = mysql_query($sql);
break;
}
}
if ($success === true) {
$output = ['success'=>'Upload Success'];
} elseif ($success === false) {
$output = ['error'=>'Error while uploading images. Contact the system administrator'];
foreach ($paths as $file) {
unlink($file);
}
} else {
$output = ['error'=>'No files were processed.'];
}
echo json_encode($output);
?>
พอกด del แล้วขึ้นแบบนี้อ่ะค่ะ ต้องทำยังไงค่ะ เพราะข้อมูลไม่มีรึเปล่าค่ะ พอไม่มีมันก็โชว์แบบนี้ขึ้นมาค่ะ งง มากค่ะ
รบกวนช่วยดูให้หน่อยได้ไหมค่ะ
คำแนะนำ และการใช้งาน
สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก
- ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา
โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ