파일 업로드시 파일명 추출
페이지 정보
작성자 서방님 댓글 0건 조회 130회 작성일 07-08-22 10:01본문
<script type="text/javascript">
function test()
{
var fname=document.all.myfile.value;
// input type=file에서 넘어오는 value(파일경로)의 공백과 역슬래쉬를 다음과 같이 치환 한 후 split을 합니다.
var arr=("file:///"+fname.replace(/ /gi,"%20").replace(/\/gi,"/")).split("/");
alert("파일명 : " + arr[arr.length-1]);
}
</script>
<input type="file" name="myfile" size="60" OnChange="test();">
댓글목록
등록된 댓글이 없습니다.