DcatAdmin开发集锦(2):屏蔽OSS找不到文件错误

新增/编辑页面,若远程文件不存在,则删除数据库文件字段记录

 $id = \request('article');
      if($id){$res = Article::find($id);
      if($res->photo != ''){
        $handle= @fopen('http://static.abc.com/'.$res->photo,'r');
          if (!$handle) {
              $res->photo = null;
              $res->save();
          }
      }
    }

猜你喜欢

转载自blog.csdn.net/sinat_37390744/article/details/111356011