Delete a file from upload folder in PHP
How to delete a file from upload folder This tutorial teaches you how to delete a file/files from the specific folder using PHP. Sometimes while deleting a record from database table, you also need to delete an image/file from the uploaded folder which is associated to that record. For example, if you are removing a product from the table, at the same time, you also need to remove an uploaded product-image. So For this, In PHP, there is a function called unlink(). Using unlink() function you can remove a file from the specified folder. Retrieve the product-image from database and pass it to unlink function along with full path. Syn: unlink ( "path_to_your_upload_directory/" . filename_with_extension. ); ex unlink ( "uploads/" . $ product_image ); Example Code delete_product,php <?php $ product_id = $_GET [ 'pid' ]; $con = mysqli_connect ( 'localhost' , 'root' , '' , 'productsdb' ); $SQL 1 =