jay_jg Posted November 24, 2014 Share Posted November 24, 2014 I have this script from http://lampload.com/component/option,com_jdownloads/Itemid,382/cid,69/task,view.download/ (I am not using a database) I can upload images fine, I can view files, but I want to delete them. When I press the delete button, nothing happens http://www.jayg.co.uk/gallery6/upload_gallery.php <form> <?php $dir = dirname(__FILENAME__)."/images/gallery" ; $files1 = scandir($dir); foreach($files1 as $file){ if(strlen($file) >=3){ $foil = strstr($file, 'jpg'); // As of PHP 5.3.0 $foil = $file; $pos = strpos($file, 'css'); if ($foil==true){ echo '<input type="checkbox" name="filenames[]" value="'.$foil.'" />'; echo "<img width='130' height='38' src='images/gallery/$file' /><br/>"; // for live host //echo "<img width='130' height='38' src='/ABOOK/SORTING/gallery-dynamic/images/gallery/ $file' /><br/>"; } } }?> <input type="submit" name="mysubmit2" value="Delete"> </form> any ideas please? thanks Link to comment https://forums.phpfreaks.com/topic/292681-display-images-from-folder-and-delete-images/ Share on other sites More sharing options...
ginerjm Posted November 24, 2014 Share Posted November 24, 2014 Please post your code in a more readable fashion and properly. Link to comment https://forums.phpfreaks.com/topic/292681-display-images-from-folder-and-delete-images/#findComment-1497547 Share on other sites More sharing options...
QuickOldCar Posted November 24, 2014 Share Posted November 24, 2014 I don't see anywhere where you delete files unlink() Be careful with this so you don't delete files accidentally. so something like this if(isset($_GET['filenames'])){ foreach($_GET['filenames'] as $del){ unlink($dir."/".$del); } } This is the simple explanation, you are gonna want to do a pile of checking and changes before allowing a delete coming from the browser Link to comment https://forums.phpfreaks.com/topic/292681-display-images-from-folder-and-delete-images/#findComment-1497554 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.