控制器调用
/** * [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; }