上传/下载权限
我目前有一个公众上传文件的文件夹。
我希望能够通过链接下载这些文件,但无法浏览上传文件夹。但与此同时,我需要保持该文件夹可写以进行上传。
我需要设置什么权限?
干杯, 道格
I currently have a folder which the public uploads files to.
I want to be able to download these files via a link, but not to be able to browse the upload folder. But at the same time, i need to keep that folder writable for uploads.
What permissions would I need to set?
Cheers,
Doug
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
打开当前文件夹中的
.htaccess
文件,如果不存在则创建它。如果
Options Indexes
存在,请将其修改为Options -Indexes
或添加Options -Indexes
作为新行。保存文件并退出。
您可能需要重新启动 Apache。
Open the
.htaccess
file in your current folder, or create it if it doesn't exist.If
Options Indexes
exists modify it toOptions -Indexes
or else addOptions -Indexes
as a new line.Save the file and exit.
You might need to restart Apache.
这可能最好在上传文件夹中使用
.htaccess
文件,将此代码添加到.htaccess
文件中以防止该文件夹的目录列表:或者
使用 IndexIgnore 您可以更改将通配符 * 添加到要忽略的扩展名列表。这允许您执行以下操作:
目录列表中不会显示任何 gif 或 jpg,而是显示其他所有内容。
这将允许您保留现在使用的任何权限,但防止人们直接查看您在该文件夹中上传的所有内容。
This is probably best with an
.htaccess
file inside your upload folder, add this code inside the.htaccess
file to prevent directory listings for that folder:Or
With IndexIgnore you can change the wildcard * to a list of extensions you want to ignore. This allows you to do something like:
Which will not show any gif or jpg's in the directory listing but everything else.
This will allow you to keep whatever permissions your using now but prevent people from directly viewing everything you have uploaded in that folder.