我需要实现图像上传,按钮旁边会出现一个缩略图..我已经使用函数“getAsDataURL”实现了它,......它在chrome和safari中不起作用......任何解决方案?
<script type="text/javascript">
function setImage(file) {
if(document.all)
document.getElementById('prevImage').src = file.value;
else
document.getElementById('prevImage').src = file.files.item(0).getAsDataURL();
if(document.getElementById('prevImage').src.length > 0)
document.getElementById('prevImage').style.display = 'block';
}
</script>
<div class="uploading_block_inner">
<div class="uploaded_img_inner"><img id="prevImage" style="display:none;" width="91" height="91" /></div>
<div class="submit_button_upload">
<div class="upload"><input type="file" id="" name="myImage" onchange="setImage(this);" /></div>
</div>
<div class="upload_submit_inner"><input type="submit" name="" value="" /></div>
</div>