你能限制输入类型=文件的位置吗?

发布于 2024-09-03 05:20:38 字数 103 浏览 7 评论 0原文

当用户选择使用输入类型=文件按钮浏览文件时,是否有办法将用户限制到服务器上的文件夹?

例如:如果您希望用户选择仅存在于服务器图像文件夹中的图像,以防止他们搜索和上传自己的图像。

Is there a way to restrict the user to a folder on the server when they choose to browse for a file using the input type=file button?

for example: If you have images you want the user to choose from that only exist in the server's image folder to prevent them from search for and uploading their own images.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

情丝乱 2024-09-10 05:20:38

当用户使用输入文件浏览时,他浏览的是自己的文件系统。所以我不知道如何限制他们搜索服务器上的内容。另外,如果用户无法上传文件,那么文件input的目的是什么?

When the user browses using an input file, he browses his own filesystem. So I don't see how you can restrict them to searching what is on the server. Also, what is the purpose of the file input if the users can't upload files ?

薔薇婲 2024-09-10 05:20:38

那么您的用例是让用户为 Web 应用程序中的某些内容选择图像?

那么输入为 type=file 的表单就不是您所需要的。

表单在用户计算机上的浏览器上下文中填充数据。这意味着用户可以访问该计算机上的文件,但无法访问运行 Web 应用程序的服务器。您可能想要的是一个在服务器上生成并填充可用图像的页面,或者提供可用图像的搜索功能的页面。

如果我错了请纠正我:)

So your use-case is to have the user select an image for something in a web application?

Then a form with an input of type=file is not what you need.

A form is filled with data in the context of the user's browser on her computer. That means the user has access to files on that computer and cannot access the server where the web application is running. What you probably want is a page that is generated on the server and filled with the available images or that provides a search function for available images.

Correct me if I'm wrong :)

若能看破又如何 2024-09-10 05:20:38

当您希望用户从服务器上的某个位置选择图像时,您无论如何都不会使用文件上传,因为它们已经在服务器上。

使用单选按钮或旁边的其他按钮依次显示图像。

When you want the user to select images from somewhere on the server you wouldn't use a file upload anyway, as they are already on the server.

Show the images one after the other with a radio button or something besides it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文