我想使用codeigniter从目录中删除图像..
我尝试了很多,但每次都发出警告......那条消息:
unlink():http不允许取消链接
我试过了。
请说出这是真的,还是一切都错了?
****/* $f = $this->input->post("imgs"); //this is the file name come from view
$directory1 = "assets/images/";
$paths = base_url().$directory1.$f;
$dest = base_url().$directory1."imgx/".$f;
$rnm =$paths."_deleted_".$this->input->post('ida');
opendir(base_url().directory1);
//echo $paths;
/*if(file_exists($paths))
echo "exists";
else
echo "<img src='".$paths."'>"; echo "not exists"; //shows not exists but load the image
if(unlink($paths)) {
echo 'deleted successfully';
}
else {
echo 'errors occured'; //shows eror occured
}
//exit;
//unlink($paths);
/*@chmod(base_url().'assets/images/'.$f, 0750);
@unlink(base_url().'assets/images/'.$f);*/
//rename($paths,$rnm);*/
如何摆脱这个...... plz帮助
答案 0 :(得分:0)
使用服务器中的物理路径删除文件,而不是使用url。
将以下内容替换为物理路径
$paths = base_url().$directory1.$f;
答案 1 :(得分:0)
尝试使用此..这对我有用。定义路径时不要使用base_url()。而是以这种方式定义特定文件的路径:
$paths ='./assets/images/'.$f;
$dest ='./assets/images/'.$f;