你能限制输入类型=文件的位置吗?
当用户选择使用输入类型=文件按钮浏览文件时,是否有办法将用户限制到服务器上的文件夹?
例如:如果您希望用户选择仅存在于服务器图像文件夹中的图像,以防止他们搜索和上传自己的图像。
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当用户使用
输入文件
浏览时,他浏览的是自己的文件系统。所以我不知道如何限制他们搜索服务器上的内容。另外,如果用户无法上传文件,那么文件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 fileinput
if the users can't upload files ?那么您的用例是让用户为 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 :)
当您希望用户从服务器上的某个位置选择图像时,您无论如何都不会使用文件上传,因为它们已经在服务器上。
使用单选按钮或旁边的其他按钮依次显示图像。
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.