mercredi 4 novembre 2015

Deleting a particular file in php

I am practicing uploading and deleting files in php and I've encountered a problem.

I have this code:

if($files)
                {
                    foreach($files as $file)
                    {
                        echo '<a href="files_storage/'.$file.'" download>'.$file.'</a><br>';
                    }
                }
                else
                {
                    echo 'There are currently no files.';
                }

It displays all files from a directory. I want to add a delete button for every file. Something like this:

enter image description here

Should I create different form for every file? If I do so, how would I identify which file to be deleted when a form is submitted? Any suggestions?

Aucun commentaire:

Enregistrer un commentaire