首页 > 代码库 > 实时图片显示

实时图片显示

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<form action="./myta.php" method=‘post‘ target="" id=‘myfor‘ enctype="multipart/form-data">
<img src=http://www.mamicode.com/‘‘ id=‘im‘>
<input name=‘text‘ type=‘file‘ id=‘tt‘ value=http://www.mamicode.com/‘1‘>
<input type=‘submit‘>
</form>
</body>
</html>
<script src=http://www.mamicode.com/‘./jquery-1.12.4.js‘></script>

<script>

$(‘#tt‘).change(function(){
var img=$(this)[0].files[0];
var url=window.URL.createObjectURL(img)
$(‘#im‘).attr(‘src‘,url);
// alert(url);


})


</script>

实时图片显示