控制器调用

        /**
         * [delimg 删除单张图片]
         * @return [type] [description]
         */
        public function delimg(){
            if (request()->isPost()) {
                $pic = input('request.pic');
                //$pic为文件路径
                return delimg($pic);
            }
        }    

 

 

公共方法

/**
 * [delimg 删除文件]
 * @param  [type] $pic [description]
 * @return [type]      [description]
 */
function delimg($pic){

    $path = __FILE__;
    $paths = substr($path,0,strpos($path,'application'));
    $pic1 = $paths."public" .DS . $pic;
    if(file_exists($pic1)){

        @unlink($pic1);

        return true;
    }
    return false;
}

 

相关文章:

  • 2021-12-12
  • 2021-11-17
  • 2022-12-23
  • 2021-08-09
  • 2022-12-23
  • 2022-12-23
  • 2021-09-30
猜你喜欢
  • 2021-10-17
  • 2022-12-23
  • 2022-12-23
  • 2021-12-03
  • 2021-12-31
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案