In my program i have some files in "temp" folder...that contain the fillowing files
hari8975495.jpg
hari8975408.jpg
guru9843.jpg
main8457.jpg
hari89749957.gif
i want to delete all the file starting with hari...how i do this.....But i put unlink(temp\hari*.*);
but it so error....
Delete a file...
Moderator: General Moderators
-
panprasath
- Forum Newbie
- Posts: 19
- Joined: Thu Jul 24, 2008 3:35 am
- Location: Chennai,Tamilnadu,India
-
WebbieDave
- Forum Contributor
- Posts: 213
- Joined: Sun Jul 15, 2007 7:07 am
-
php000developer
- Forum Newbie
- Posts: 4
- Joined: Fri Jul 25, 2008 6:24 am
Re: Delete a file...
first make a form and add selecting box for selecting the files to delete from database
add this code to make a deleting form
<form action="delete1.php" method="post">
<select name="area" >
<? $res=mysql_query("SELECT * FROM area order by area");
if (mysql_num_rows($res)== 0)
echo "There is no data";
else
for($i=0;$row=mysql_fetch_assoc($res);$i++)
{
print "<option>$row[area]</option>";
}
?></select><INPUT TYPE=SUBMIT NAME="submitform" VALUE="Remove"></form>
then add this code to "delete1.php" file, you can change the name of that file but remember change in both files
<?
$area=$_POST['area'];
$name=$_POST['name'];
$query="DELETE from tablename WHERE name='".$fieldname."'";
$query1="DELETE from area WHERE area='".$area."'";
mysql_query($query) or die ('Cannot delete file');
mysql_query($query1) or die ('Cannot delete file');
echo "Record Deleted!";
?>
add this code to make a deleting form
<form action="delete1.php" method="post">
<select name="area" >
<? $res=mysql_query("SELECT * FROM area order by area");
if (mysql_num_rows($res)== 0)
echo "There is no data";
else
for($i=0;$row=mysql_fetch_assoc($res);$i++)
{
print "<option>$row[area]</option>";
}
?></select><INPUT TYPE=SUBMIT NAME="submitform" VALUE="Remove"></form>
then add this code to "delete1.php" file, you can change the name of that file but remember change in both files
<?
$area=$_POST['area'];
$name=$_POST['name'];
$query="DELETE from tablename WHERE name='".$fieldname."'";
$query1="DELETE from area WHERE area='".$area."'";
mysql_query($query) or die ('Cannot delete file');
mysql_query($query1) or die ('Cannot delete file');
echo "Record Deleted!";
?>
-
panprasath
- Forum Newbie
- Posts: 19
- Joined: Thu Jul 24, 2008 3:35 am
- Location: Chennai,Tamilnadu,India
Re: Delete a file...
Thank you for your help...