Kommentar: In diesem Artikel wird hauptsächlich das Vorschau -Beispiel des HTML5 -Bild -Uploads vorgestellt. Freunde, die es brauchen, können sich darauf beziehen.
<! DocType html>
<html lang = "zh-cn">
<kopf>
<meta charset = "utf-8" />
<meta content = "edielei" />
<title> html5 Bild -Upload -Vorschau </title>
<script type = "text/javaScript" src = "<a href =" http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js "> </script"> </script </a >>
<script type = "text/javaScript">
$ (function () {
$ ('#img'). ändern (function () {
var file = this.files [0]; // Wählen Sie die hochgeladene Datei aus
var r = neuer fileReader ();
R.ReadasDataurl (Datei); // Base64
$ (r) .load (function () {
$ ('div'). html ('<img src = "' + this.result + '" />');
});
});
});
</script>
</head>
<body>
<h3> HTML5 -Bild -Upload -Vorschau </H3>
<Eingabe type = "Datei" "Accept =" Image /*" />
<div> </div>
</body>
</html>