Question

I have looked at most of the suggested questions but can't find the answer I need.

I am using cakephp 2.x and I have a controller function as follows:

public function removeImage($image) {
    $p = '/explicit/path/to/website/domain.com/www/app/webroot/img/weddings/';
    $command = "rm ".$p.$image."*.jpg";
    $output = shell_exec($command);
    /* do something with $output */
}

The view file has this link

<?php echo $this->Html->link('remove image', array('controller' => 'weddings', 'action' => 'removeImage', 'p'.$aWeddings[$wedding['Wedding']['zenId']]['TitlePhoto']['Id'])); ?><?php endif; ?>

which gives me a string like 'p12321223213'.

I set the permissions to user:www-data and rw-rw-r--.

Now, when I click the link, not only does it not delete the file but it changes the permissions to www-data:www-data and rw-r--r--

the user is a member of www-data group.

Why is it not deleting the files?

Thanks

Was it helpful?

Solution

Try using native PHP function for deleting files: unlink().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top