Commentaire: Cet article présente principalement l'exemple d'aperçu du téléchargement d'image HTML5. Les amis qui en ont besoin peuvent y faire référence.
<! Doctype html>
<html lang = "zh-cn">
<adal>
<meta charset = "utf-8" />
<meta content = "eielei" />
<Title> HTML5 Image Téléchargez l'aperçu </TITAL>
<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'). Change (function () {
var fichier = this.files [0]; // sélectionnez le fichier téléchargé
var r = nouveau fileReader ();
R.Readasdataurl (fichier); // Base64
$ (r) .load (function () {
$ ('div'). html ('<img src = "' + this.result + '" />');
});
});
});
</cript>
</ head>
<body>
<H3> HTML5 Image Téléchargez l'aperçu </h3>
<input type = "file" accepte = "image / *" />
<div> </div>
</docy>
</html>