How to delete image from folder in PHP

[dm_code_snippet background=”yes” background-mobile=”yes” bg-color=”#abb8c3″ theme=”dark” language=”php” wrapped=”no”]

<button type=”submit” name=”data_send_btn”>Submit</button>

<?php

if(isset($_POST[‘data_send_btn’])){

$img = “dolphin.jpg”;

$imgpath = “assets/img/”.$img;

unlink( $imgpath ); // unlink function is help to remove image from specific folder.

}

?>

[/dm_code_snippet]

Leave a Reply

Your email address will not be published.