當我選擇一個圖像時,有時它不會顯示,但是當我再次單擊時,圖像顯示。使用jQuery顯示圖像
jQuery的
$('#morefiles').change(function (event) {
if (!(/\.(gif|jpg|jpeg|tiff|png)$/i).test($(this).val())) {
$ionicPopup.alert({
title: 'Message',
template: 'You must select an image file only !'
});
$('#morefiles').val('');
} else {
var obj = {};
obj.key = event.target.files[0];
obj.value = URL.createObjectURL(event.target.files[0]);
$scope.items.push(obj);
console.log(JSON.stringify(obj));
$('#morefiles').val(obj);
}
});
HTML
<input type="file" multiple="" id="morefiles" accept="image/*" >
如何解決這個問題呢?當用戶選擇一個圖像時,我需要顯示圖像。提前致謝。
我認爲這會幫助你更多http://stackoverflow.com/questions/28235246/angularjs-display-base64-image –
你在哪裏點擊來顯示圖像? – sideroxylon
感謝重播@Prajwal KM,但我不用於存儲圖像在遠程服務器我只用於顯示圖像 –