2014-11-14 1 views
0

특정 경로로 파일 탐색을 제한 할 수있는 방법이 있습니까?특정 경로로만 파일 찾아보기 제한

<input type="file" name="pic" > 

경로는 로컬 파일 시스템 일 수도 있고 아닐 수도 있지만 네트워크 또는 다른 위치에있을 수도 있습니다.

이 작업을 수행 할 수 있습니까? 내가 JSP +를 사용하고

은 1.x에서에게

감사

답변

2

당신은 보안상의 이유로 파일의 위치를 ​​설정할 수 없습니다 스트럿.

그러나 입력 요소에 mime-type을 사용하여 accept 속성을 설정하여 허용되는 파일 형식을 제한 할 수 있습니다.

<input type="file" name="pic" accept="image/*" /> 

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"). 
1

번호 당신은 할 수 없습니다. 웹 서버는 사용자 로컬 파일 시스템에 대해 이러한 제한을 수행 할 수 없습니다. 누구든지이 작업을 수행 할 수 있다면 해킹으로 간주합니다.