符号链接在 Ubuntu 中不起作用
Symlinking doesn't work in Ubuntu
我试过 ln -s ./storage/profile_pictures/* ./public/profile_pictures/
但这使我的图像变得毫无用处。在我的 Finder 中,它显示 image.png (alias)
,但在预览中它不显示图片,只显示一个白色页面图标。
我该如何解决这个问题?
你差不多明白了。如果你想从 storage/profile_pictures/
到 public/profile_pictures/
创建一个符号 link,下面的方法应该有效:
ln -s storage/profile_pictures public/profile_pictures
请注意 public/profile_pictures
必须还不存在。
此 link 将允许您以 storage/profile_pictures/1.jpg
和 public/profile_pictures/1.jpg
访问图片 1.jpg
正如 morido 所说,您希望 public/profile_pictures
成为目录 storage/profile_pictures
的符号链接。所以不要使用 ./storage/profile_pictures/*
,因为 shell 会将其扩展为 ./storage/profile_pictures/
.
中所有文件的列表
其次,您使用的是相对路径:
ln -s ./storage/profile_pictures ./public/profile_pictures
说 "make a symlink in ./public/profile_pictures
that points to ./storage/profile_pictures
"。第一个参数是相对于第二个参数的。也就是说,您最终会得到指向目录 ./public/profile_pictures/storage/profile_pictures
的 ./public/profile_pictures/profile_pictures
,该目录可能不存在。
最简单的方法可能是
cd public
ln -s ../storage/profile_pictures profile_pictures
我试过 ln -s ./storage/profile_pictures/* ./public/profile_pictures/
但这使我的图像变得毫无用处。在我的 Finder 中,它显示 image.png (alias)
,但在预览中它不显示图片,只显示一个白色页面图标。
我该如何解决这个问题?
你差不多明白了。如果你想从 storage/profile_pictures/
到 public/profile_pictures/
创建一个符号 link,下面的方法应该有效:
ln -s storage/profile_pictures public/profile_pictures
请注意 public/profile_pictures
必须还不存在。
此 link 将允许您以 storage/profile_pictures/1.jpg
和 public/profile_pictures/1.jpg
1.jpg
正如 morido 所说,您希望 public/profile_pictures
成为目录 storage/profile_pictures
的符号链接。所以不要使用 ./storage/profile_pictures/*
,因为 shell 会将其扩展为 ./storage/profile_pictures/
.
其次,您使用的是相对路径:
ln -s ./storage/profile_pictures ./public/profile_pictures
说 "make a symlink in ./public/profile_pictures
that points to ./storage/profile_pictures
"。第一个参数是相对于第二个参数的。也就是说,您最终会得到指向目录 ./public/profile_pictures/storage/profile_pictures
的 ./public/profile_pictures/profile_pictures
,该目录可能不存在。
最简单的方法可能是
cd public
ln -s ../storage/profile_pictures profile_pictures