<img name="img1" src="/images/bg/nophoto_s.gif" />
<input type="file" name="file1" />
<script>
$("input[name='file1']").change(function(){
$image = $("img[name='img1']");
$img = new Image();
$img.src= $(this).val();
$img.onload=function(){
alert($img.width + "," + $img.height + "," + $img.filesize);
}
$image.attr("src", $(this).val() + "?rnd="+Math.random());
});
</script>
本文介绍了一种通过JavaScript实现的文件上传功能,当用户选择文件后,程序会实时显示文件内容并提供预览功能,同时获取文件的宽度、高度和大小信息。

被折叠的 条评论
为什么被折叠?



