Today, We want to share with you PHP Remove File from Folder and Database.In this post we will show you PHP delete image from mysql to delete also from folder, hear for Delete Uploaded Files from Folder using PHP and MySQL we will give you demo and example for implement.In this post, we will learn about How to let user delete files from database and file directory path with an example.
PHP Remove File from Folder and Database
There are the Following The simple About PHP Remove File from Folder and Database Full Information With Example and source code.
As I will cover this Post with live Working example to develop creating and deleting files in php, so the php delete file in directory for this example is following below.
Delete file in PHP by using unlink function
Step 1: PHP Source code
<div id="box"> <?php $sql=mysql_query("select * from profiles limit 1"); $pdata=mysql_fetch_array($sql); ?> <img src="profiles/<?php echo $pdata['image']?>" /> <p></p> <a href="removeete.php?remove=<?php echo $pdata['profilesid']?>" class="link">Delete</a> </div>
step 2: removeete.php
<?php extract($_REQUEST); include('connection.php'); $sql=mysql_query("select * from profiles where galleryid='$remove'"); $pdata=mysql_fetch_array($sql); unlink("profiles/$pdata[image]"); mysql_query("Delete from personal where pid='$remove'"); header("Location:index.php"); ?>
I hope you get an idea about PHP Remove File from Folder and Database.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.