Reputation: 7953
is there any way to restrict file browsing to a specific path?
<input type="file" name="pic" >
the path may or may not be in local file system, it can also be in network or any other location.
is it possible to do this?
i am using JSP+struts 1.x
thanks
Upvotes: 0
Views: 140
Reputation: 3908
You can't set the location of the file due to security reasons.
But you can limit the accepted file types by setting a accept attribute with a mime-type on the input element.
<input type="file" name="pic" accept="image/*" />
See the input element specification:
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").
Upvotes: 2
Reputation: 91
No. You cannot. Web server cannot have that privilege to do such a restriction on user local file system. If anyone can do this, I treat this as a hacking.
Upvotes: 1