且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

预览图像文件上传

更新时间:2023-11-25 17:31:22

以为你需要这样的



http://www.aspdotnet-suresh.com/2014/03/jquery-preview-image-before-upload-using-fileupload.html [ ^ ]



AnandKumar Devendran
thought u need like this

http://www.aspdotnet-suresh.com/2014/03/jquery-preview-image-before-upload-using-fileupload.html[^]

AnandKumar Devendran


使用示例代码:



Use the Sample Code as :

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery Preview Image before upload</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
function Preview(input) {
if (input.files && input.files[0]) {
var filerdr = new FileReader();
filerdr.onload = function(e) {


('#imgprvw')。attr('src',e.target.result);
}
filerdr.readAsDataURL(input.files [0]);
}
}
< / script>
< / head>
< body>
< form id =form1runat =server>
< input type =filename =filUploadid =filUploadonchange =Preview(this)/>
< / form>
< / body>
< / html>
('#imgprvw').attr('src', e.target.result); } filerdr.readAsDataURL(input.files[0]); } } </script> </head> <body> <form id="form1" runat="server"> <input type="file" name="filUpload" id="filUpload" onchange="Preview(this)" /> </form> </body> </html>