Latest web development tutorials

HTML DOM 파일 업로드 값 속성

참조 객체 파일 업로드 파일 업로드 객체

정의 및 사용

값 속성 반환 선택된 요소의 <입력 유형 = "파일"> 파일의 경로와 이름을.

IE, 구글 크롬, 오페라, 파이어 폭스에서 사파리 브라우저 값 속성은 선택된 파일 잘못된 경로 이름을 반환합니다.

참고 : 보안상의 이유로이 속성은 읽기 전용입니다.

문법

fileuploadObject.value


브라우저 지원

Internet ExplorerFirefoxOperaGoogle ChromeSafari

모든 주요 브라우저는 속성 값을 지원


선택한 파일 이름을 표시합니다 :

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult(){
    var x=document.getElementById("fname").value;
    alert(x);
}
</script>
</head>
<body>

<form>
选择一个文件上传:
<input type="file" id="fname" size="50"/>
</form>
<button type="button" onclick="displayResult()">显示文件路径</button>

</body>
</html>

»시도


참조 객체 파일 업로드 파일 업로드 객체