Blogger Information
Blog 39
fans 1
comment 0
visits 62586
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
删除服务器上传的文件
Dai的博客
Original
949 people have browsed it

1、把上传的文件路径保存至数据库当中QQ截图20170808132758.png

2、在文件前加上物理地址(即你所上传的服务器物理地址)

$_SERVER["DOCUMENT_ROOT"]//获取服务器物理地址

3、把地址补全

$url = $this -> db -> where('id',$id) -> field('logo')-> find();//从数据库当中找到当前对象的上传文件路径
 $url = $_SERVER["DOCUMENT_ROOT"].'/'.$url['logo'];//地址补全

4、删除文件

unlink($url);

 实例:

 // 查找出logo的物理地址
         $url = $this -> db -> where('id',$id) -> field('logo')-> find();
         if ($url != '') {
           //upload/20170808\1858a5c774bb86287f1a3fe8c5ce816d.png 
           $url = $_SERVER["DOCUMENT_ROOT"].'/'.$url['logo'];
          unlink($url);
         }


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post