Deleting a Specific Image from a File

Asked

Viewed 69 times

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 be able to delete a photo chosen by him from his folder, The controller: `

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

The 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!

  • https://stackoverflow.com questions português

  • Welcome to the Stackoverflow in Portuguese. As the name suggests, the official language used here is Portuguese. So, could you please translate your question? If you prefer, you can also ask the same question on Stackoverflow website in English.

  • Sorry I don’t understand! Prefer the question in English?

  • Yes of course I will translate! I thank you from already help!

  • @Gabrielgomes the link edit is below the tags, to format the code, just select it and hit the shortcut CTRL+K or in the boar {} in the editor, enjoy making the Tour to learn how the site works.

  • is already edited @Noobsaibot

Show 1 more comment

1 answer

0

since you do not indicate which error you are getting, it becomes more difficult to help.

but it may be for lack of loading the lib of the responsalvel condingniter by the files

you can do this by adding the following line of code to your controller $this->load->helper('file');

then you may be having trouble using the absolute path of the file

  • Yes it is already solved, besides missing the lib also had several other problems that ended up being solved.

  • finalizes the tikect

Browser other questions tagged

You are not signed in. Login or sign up in order to post.