dongtang6681 2013-03-06 16:51
浏览 247
已采纳

PHP unlink不起作用

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?

  • 写回答

2条回答 默认 最新

  • drk7700 2013-03-06 17:00
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Fluent udf 编写问题
  • ¥15 求合并两个字节流VB6代码
  • ¥15 Pyqt 如何正确的关掉Qthread,并且释放其中的锁?
  • ¥30 网站服务器通过node.js部署了一个项目!前端访问失败
  • ¥15 WPS访问权限不足怎么解决
  • ¥15 java幂等控制问题
  • ¥15 海湾GST-DJ-N500
  • ¥15 氧化掩蔽层与注入条件关系
  • ¥15 Django DRF 如何反序列化得到Python对象类型数据
  • ¥15 多数据源与Hystrix的冲突