0

Hi all, here i got a problem where i want to delete file uploaded..my script
just remove from database but not remove from directory.. how can i delete from database and directory at a same time?? Please help me..

3
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by HasNor
0

this my delete code

<?php 
include 'connection/db_connect.php';
$attcid = $_GET['attcid'];
$username = $_GET['username'];

$sql="DELETE FROM attachment WHERE attcid = '$attcid'";
mysql_query($sql);

?>
1

try.. make sure the directory and the file name are properly assigned below.

if (file_exists($attcid."whatever.extensionOfFile"){
						@unlink($attcid."whatever.extensionOfFile") ;
					}
else{

echo "Are you kidding me? This file don't even exist. I already looked.";

}

Edited by veedeoo: n/a

Votes + Comments
Useful post
0

thanks veedeoo for suggestion..still not work.. hurm.. :(

0

unlink works, if it doesn't then there's problem with your path, if you doubt it's functionality, try doing simple test, like unlink(test.php); putting unlink script and test.php into the same directory

0

thanks all!! it works!! when second try i change by calling the file name.. hurmm
thank you so much!! This my latest code.. :)

<?php
$fileName=$_GET['fileName'];
$sql="DELETE FROM attachment WHERE fileName = '$fileName'";
unlink("path".$fileName);
mysql_query($sql);
?>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.