1
I’m working on a personal cloud for my girlfriend because her iCloud is full.
Basically this is what’s making it all work:
<?php
$dirname = "uploads/";
$images = glob($dirname."*.{jpg,jpeg,png,gif,JPG,JPEG,PNG,GIF}", GLOB_BRACE);
usort($images, create_function('$b,$a', 'return filemtime($a) - filemtime($b);'));
foreach($images as $image) {
echo '
<a href="'.$image.'">
<img class="img-grid" src="'.$image.'" />
</a>';
}
?>
Everything works perfectly but I need to figure out a way to get a button or something close to the images (or even inside the image) so that it can erase the image as needed.
Remember that she uses mostly by smartphone, having need to be something easy to run on the touchscreen. I also know that the ideal would be to use unlink(), but I don’t know how to make it work. I’m new to PHP.
At first I thought about the solution below, but I accept any idea! (When clicking, pop-up appears OR redirect to a page of the image where it can be deleted)
Your difficulty is in creating the functionality to delete the image or add the delete button in the demonstrated way?
– Marcelo de Andrade
Both! I tried several times and unsuccessfully, even ended up deleting the entire uploads directory unintentionally once
– Gerson Bandeira
Since you’re new to PHP, because instead of killing yourself, you don’t put a free image manager on your server, see this one or this one or this one
– Ivan Ferrer
But the intention is to improve my knowledge friend rs
– Gerson Bandeira
You will improve your knowledge using third party library. Much more than doing it all alone without inheriting any knowledge.
– Ivan Ferrer
But anyway I need a user-friendly interface, it’s my girlfriend who’s using, I don’t even need this cloud, this is f*da :/
– Gerson Bandeira
But anyway, to make an exclusion button is very simple, you can even do a mouse while passing the mouse... and put an action on this button. and delete using ajax.
– Ivan Ferrer
Here is an example I did using javascript only.
– Ivan Ferrer
Actually thinking better the delete button on the image/ next to the image would be something impractical, given that it uses only on the smartphone and the images get very small on the screen, which can lead to a miss click. Maybe I have more work than I think.
– Gerson Bandeira
I updated the idea in the post.
– Gerson Bandeira
For now I’ve made an example of the button, as soon as I can answer full. jsfiddle
– Marcelo de Andrade