Delete image from folder in php - Mostlikers

15 July, 2014

Delete image from folder in php

Some programmer using image upload coding that image file move on particular folder. after delete  that database record data only deleteed but image stay on same folder only it's not delete. So add below code remove deleted record folder image.  

unlink('foldername/'.$imagename); 

Sample code 

$Q2="SELECT * FROM image WHERE id='".$id."'";
$row2 = dbRow($Q2);
$image_path=$row2['image'];
if(file_exists('imagesfolder/'.$image_path))unlink('imagesfolder/'.$image_path);



below write your delete record query.

No comments:

Post a Comment