Home / Web Development / PHP / Delete image in a folder and database Using PHP

Delete image in a folder and database Using PHP

Everybody know how to delete the content like datas and images from database using php code. But nobody try to delete the image from folder also. The following code will explain how to delete the data from database and folder using unlink command in php and wordpress page.

<?php>
$slot=$_GET[‘cat’];
$complete = $wpdb->get_results(“select * from babyitemdetails where itemid=’$slot'”);
foreach($complete as $value)
{
$productimage=$value->itemimage;
}
$path=”dbimage/”.$productimage;
unlink($path);
$sqla=”Delete from babyitemdetails where itemid=’$slot'”;
$resulta=mysqli_query($con,$sqla);
</?php>

Happy Coding

Leave a Reply

Your email address will not be published. Required fields are marked *

Social Media Auto Publish Powered By : XYZScripts.com