주석 :이 기사는 주로 HTML5 이미지 업로드의 미리보기 예제를 소개합니다. 필요한 친구는 그것을 참조 할 수 있습니다.
<! doctype html>
<html lang = "zh-cn">
<헤드>
<meta charset = "utf-8" />
<meta content = "edielei" />
<title> html5 이미지 업로드 미리보기 </title>
<script type = "text/javascript"src = "<a href ="http://ajax.googleapis.com/jax/libs/jquery/1.7.7.2/jquery.min.js "> </script"> "> </script </script </a >>
<script type = "text/javaScript">
$ (function () {
$ ( '#img'). Change (function () {
var file = this.files [0]; // 업로드 된 파일을 선택합니다
var r = 새로운 filereader ();
R.Readasdataurl (파일); // base64
$ (r) .load (function () {
$ ( 'div'). html ( '<img src = "' + this.result + '" />');
});
});
});
</스크립트>
</head>
<body>
<H3> HTML5 이미지 업로드 미리보기 </h3>
<입력 유형 = "파일"accept = "image /*" />
<div> </div>
</body>
</html>