I have a multi-delete feature in one of my CMS solutions, and I have following code:
public function actionDelete() {
if(Yii::app()->request->isPostRequest) {
if(isseT($_POST['submit'])) {
if(isset($_POST['delete']) && (sizeof($_POST['delete']))) {
foreach($_POST['delete'] as $i => $items) {
$model[$i] = Pages::model()->findByPk((int)$items);
if(!is_null($model[$i])) {
$image[$i] = $model[$i]->image;
if($model[$i]->delete()) {
if(!unlink($image[$i])) {
die('Unable to delete Page Image.');
}
}
}
}
}
}
}
$this->redirect('/admin/pages');
}
This is the action of a Yii controller, and on EVERY page there is a value filled in the "image" field/column.
After I invoke this action with post data, it acctually deletes the records from the database table, but it does not remove the pictures and images from the file system, and the script never comes up to this point: die('Unable to delete Page Image.');
Is it possible that PHP strips and ignores the unlink
function, mostly on production / live servers?
Is it possible that PHP strips and ignores the unlink function, mostly on production / live servers?
No, absolutely not (unless they've disabled that function but that should throw an error). It's either a logic error, permissions error, or pathing error.