สอบเรื่องการ del file ค่ะ

ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา สอบเรื่องการ del file ค่ะ

สอบเรื่องการ del file ค่ะ
ถ้าต้องการลบไฟล์ต้องทำยังไงค่ะ หาโค้ดมากหลายวันแล้วค่ะ ช่วยดูให้หน่อยได้ไหมค่ะ ว่าต้องใส่ 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 แล้วขึ้นแบบนี้อ่ะค่ะ ต้องทำยังไงค่ะ เพราะข้อมูลไม่มีรึเปล่าค่ะ พอไม่มีมันก็โชว์แบบนี้ขึ้นมาค่ะ งง มากค่ะ
รบกวนช่วยดูให้หน่อยได้ไหมค่ะ



Chickenkook 183.88.103.xxx 17-11-2015 12:03:56

คำแนะนำ และการใช้งาน

สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก


  • ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
  • เปลี่ยน


    ( หรือ เข้าใช้งานผ่าน Social Login )

 ความคิดเห็นที่ 1
ลบไฟล์ น่าจะต้องไปแสดงรายการก่อนแล้วก็ลบแบบปกติ โค้ดส่วนที่ลบไฟล์ใน ajax น่าจะเป็นคนละตัว


ninenik 183.89.95.xxx 17-11-2015
 ความคิดเห็นที่ 2
คือ งง นะค่ะ พอกดลบที่ถังขยะตามรูป ที่ดึงออกมาจากดาต้าเบสค่ะ มันไม่สามารถลบได้ แล้วใน เว็บนี้อ่ะค่ะ http://plugins.krajee.com/file-input-ajax-demo/7 มันสามารถลบได้ แต่แยกไฟล์ upload กับ del ออกจากกันค่ะ แต่ไฟล์ del นี่ไม่รู้จะเริ่มต้นยังไงค่ะ ไม่ค่อยเข้าใจเท่าไหร่เลยค่ะ





chickenkook 183.88.103.xxx 17-11-2015 16:10






เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ