View Full Version : Help deleting file from server

11-19-2010, 11:17 AM
Hi all,

Please can somebody help me with my script.
The idea is that it first deletes the file off the server and then deletes all the table info for the according details, which include the stored url of the file.

I cannot get the file to delete off server mind.

Many Thanks for any hep,

$query_Recordset1 = "SELECT Images FROM testimonials WHERE Testimonial_Id=%s";

$img_dir = 'uploaded_images/';
$image_name = $row_RecordSet1['Images'];

if ((isset($_GET['del'])) && ($_GET['del'] != "")) {


$deleteSQL = sprintf("DELETE FROM testimonials WHERE Testimonial_Id=%s",
GetSQLValueString($_GET['del'], "int"));

mysql_select_db($database_localhost, $localhost);
$Result1 = mysql_query($deleteSQL, $localhost) or die(mysql_error());

$deleteGoTo = "index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $_SERVER['QUERY_STRING'];
header(sprintf("Location: %s", $deleteGoTo));

11-30-2010, 10:57 AM
make sure the path to the file is correct

I would use an absolute path...


or if your on a linux system you could use...

system('rm -f /path/file.ext');