toad78 Posted February 4, 2009 Share Posted February 4, 2009 I'm trying to delete a file from the server after the deletion is set; the record on the db deletes, but not the file. Can someone take a look at this for me? Thank you! if ((isset($_POST['empl_id'])) && ($_POST['empl_id'] != "")) { $deleteSQL = sprintf("DELETE FROM empl_dnlds WHERE empl_id=%s", GetSQLValueString($_POST['empl_id'], "int")); $image_path = '../../../info/docs/employment/'; if ((isset($_POST['empl_id'])) && file_exists($image_path.$_POST['empl_id'])) { unlink($image_path.$row_getApp['empl_dnld_fn']); } mysql_select_db($database_wvgsadmin, $wvgsadmin); $Result1 = mysql_query($deleteSQL, $wvgsadmin) or die(mysql_error()); $deleteGoTo = "empl_app_list.php"; if (isset($_SERVER['QUERY_STRING'])) { $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?"; $deleteGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $deleteGoTo)); } $colname_getApp = "-1"; if (isset($_GET['empl_id'])) { $colname_getApp = $_GET['empl_id']; } Link to comment https://forums.phpfreaks.com/topic/143841-unlink-file-from-server/ Share on other sites More sharing options...
Brian W Posted February 4, 2009 Share Posted February 4, 2009 Try: if ((isset($_POST['empl_id'])) && ($_POST['empl_id'] != "")) { $deleteSQL = sprintf("DELETE FROM empl_dnlds WHERE empl_id=%s", GetSQLValueString($_POST['empl_id'], "int")); $image_path = '../../../info/docs/employment/'; if ((isset($_POST['empl_id'])) && file_exists($image_path.$_POST['empl_id'])) { if(!is_file($image_path.$row_getApp['empl_dnld_fn'])){ die('your file path may be wrong dude'); } unlink($image_path.$row_getApp['empl_dnld_fn']); } mysql_select_db($database_wvgsadmin, $wvgsadmin); $Result1 = mysql_query($deleteSQL, $wvgsadmin) or die(mysql_error()); $deleteGoTo = "empl_app_list.php"; if (isset($_SERVER['QUERY_STRING'])) { $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?"; $deleteGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $deleteGoTo)); } $colname_getApp = "-1"; if (isset($_GET['empl_id'])) { $colname_getApp = $_GET['empl_id']; } Link to comment https://forums.phpfreaks.com/topic/143841-unlink-file-from-server/#findComment-754827 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.