unlink()不会删除数据库中的文件

问题描述:

我有问题与unlink()我以前使用过,工作正常,但在这个特定的一个它不是。将解释。unlink()不会删除数据库中的文件

这是代码

public function kill($id){ 

$post = Post::withTrashed()->where('id', $id)->first(); 



unlink(public_path(). "/" . $post->featured); 

$post->forceDelete(); 

Session::flash('success', 'Post has been permanently deleted'); 

return redirect()->back(); 
} 

和我得到这个错误 ErrorException在PostsController.php行158: 取消链接(/应用/ XAMPP/xamppfiles/htdocs中/安吉/公/ http://angie.dev/uploads/posts/1506133455image_1.jpg):没有这样的文件或目录

所以基本上是在文件名前添加“http://angie.dev/”。但是在数据库文件名中查看是正常的。我该如何摆脱它?

感谢

使用此

unlink(public_path(). str_replace("angie.dev/","/", $post->featured)); 
+0

它实际上其他全面。但是感谢您的帮助 unlink(public_path()。str_replace(“http://angie.dev/”,“/”,$ post-> featured)); –