【发布时间】:2014-11-14 09:48:35
【问题描述】:
有没有办法限制文件浏览到特定路径?
<input type="file" name="pic" >
路径可能在本地文件系统中,也可能不在本地文件系统中,也可以在网络或任何其他位置。
可以这样做吗?
我正在使用 JSP+struts 1.x
谢谢
【问题讨论】:
有没有办法限制文件浏览到特定路径?
<input type="file" name="pic" >
路径可能在本地文件系统中,也可能不在本地文件系统中,也可以在网络或任何其他位置。
可以这样做吗?
我正在使用 JSP+struts 1.x
谢谢
【问题讨论】:
出于安全原因,您无法设置文件的位置。
但是您可以通过在输入元素上设置带有 mime-type 的接受属性来限制接受的文件类型。
<input type="file" name="pic" accept="image/*" />
accept = content-type-list [CI]
This attribute specifies a comma-separated list of content types that a server
processing this form will handle correctly. User agents may use this information
to filter out non-conforming files when prompting a user to select files to be sent
to the server (cf. the INPUT element when type="file").
【讨论】:
没有。你不能。 Web 服务器不能有这样的权限对用户本地文件系统做这样的限制。如果有人能做到这一点,我将其视为黑客行为。
【讨论】: