Delete a specific Image from a File

1

I am currently working on a new project, using Codeigniter, it is my first experience and I do not find great help, I want the user to delete a photo chosen by him from his folder, The controller: '

public function delete()
    {
        delete_files('C:\wamp64\www\uploads\_back');
    }'

A view: '

{imagesback}
                                    <div class="col-sm-2">
                                        {ver}
                                    <img src="{path}" style="width: 100%; height: 100px;">
                                    <p>{name}</p>
                                    <button name="nameimagetodelete" onclick="do_delete('{name}')"></button>
                                    </div>
                                    {/imagesback}

'

and JavaScript '

script type="text/javascript">
    function do_delete(name){
        var r = confirm("You sure?");
        if (r == true) 
        {
            window.location.href = "<?php echo site_url('admin/delete');?>?name="+name;
        }
        else
        {
            x = "Action canceled";
            alert(x);
        }
    }
</script>

'

Thank you in advance!

    
asked by anonymous 08.06.2018 / 12:58

1 answer

0

Since you do not indicate which error you are getting, it makes it more difficult to help.

but may be due to lack of loading the condingniter lib responsible for the files

You can add the following line of code to your controller $ this- > load- > helper ('file');

then you may be having problems because you are using the absolute path of the file

    
08.06.2018 / 16:03