<input type="file" id="selectedPhoto" name="profilepicuploader1"
onclick="PreviewImage();" accept="image/*" />
<img id="profileImage" >
这是我的剧本:
function PreviewImage() {
document.getElementById('selectedPhoto').onchange = function(evt) {
ImageTools.resize(
this.files[0],
{
width: 150, // maximum width
height:150 // maximum height
},
function(blob, didItResize) {
// didItResize will be true if it managed to resize it, otherwise
//false (and will return the original file as 'blob')
document.getElementById('profileImage').src=window.URL.createObjectURL(blob);
})
};
}
上面的代码调整了图像的大小,并使用document.getElementById('profileImage').src = window.URL.createObjectURL(blob);
显示预览图像
但我想将预览图像值分配到输入file
类型
请事先帮助我