Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Delete an uploaded Image/(File) #447

Open
omarmounir908 opened this issue Jan 31, 2019 · 3 comments
Open

Delete an uploaded Image/(File) #447

omarmounir908 opened this issue Jan 31, 2019 · 3 comments

Comments

@omarmounir908
Copy link

Good Day,

I'm trying to remove the uploaded image/file from the folder to keep the storage clean using unlink() method

so when hitting the checkbox of delete item the below event fired

$grid->row(function ($row) {
           if (empty($row->cell('image_path')->value)) {
                unlink('uploads/images/main-slider/'.$row->cell('image_path')->value);
           }

        });

Error message:
unlink(uploads/images/main-slider/): Permission denied

your Prompt help is much appreciated

Other Question is it possible link the delete icon in the grid view with the unlink() method ?

@zofe
Copy link
Owner

zofe commented Jan 31, 2019 via email

@omarmounir908
Copy link
Author

omarmounir908 commented Feb 3, 2019

Hello Zofe,

Thanks for the quick reply,

I'm trying to remove only the image not the whole directory

$dep = Department::find(Input::get('delete'));

        $link = "uploads/images/department"."/".$dep['image_path'];
       
        echo $link;

        if (\Input::get('do_delete')) unlink($link);

now after deep testing -- the above code if i run echo $link; the full path displayed correctly
uploads/images/department/iso.jpg

however the unlink () method displays the same error message

unlink(uploads/images/department/): Permission denied

its obvious that the link inside Unlink method is not correctly displayed so can u guide me why the image name is not displayed ?

@nayi10
Copy link

nayi10 commented Jan 1, 2020

Permission denied may mean your web server doesn't have the required permissions to delete files in your images folder. You can try changing the permissions of the folder so others (other than you, or super admin) can delete files.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants