此代码适用于Google Chrome,但无法在Android浏览器上运行 这是我的链接:
echo CHtml::link(CHtml::image(Yii::app()->baseUrl . "/newmobile/icnUploadImage.gif",'',array('width'=>'55','style'=>'padding: 0 15px;')), '#', array('style' => 'right: 0.2%', 'class' => 'add_photo_btn', 'onclick' => '$("#MobileLandingPost_image_name").click(); return false;'));
这是我的剧本......
<script>
$(document).ready(function() {
var isFileInputSupported = (function () {
// Handle devices which falsely report support
if (navigator.userAgent.match(/(Android (1.0|1.1|1.5|1.6|2.0|2.1))|(Windows Phone (OS 7|8.0))|(XBLWP)|(ZuneWP)|(w(eb)?OSBrowser)|(webOS)|(Kindle\/(1.0|2.0|2.5|3.0))/)) {
return false;
}
return true;
});
if(typeof window.FileReader === 'undefined' || !isFileInputSupported()) {
$('#imageupload').remove();
} else {
$('#MobileLandingPost_image_name').change(function(evt) {
var files = evt.target.files;
var f = files[0];
var reader = new FileReader();
reader.onload = (function(theFile) {
return function(e) {
$('.add_photo_btn').html(['<img src="', e.target.result,'" title="', theFile.name, '" style="padding: 0 15px;" width="75" height="67" />'].join(''));
};
})(f);
reader.readAsDataURL(f);
});
}
});
答案 0 :(得分:0)
试试这个:
$('.add_photo_btn').html('<img src="'+ e.target.result+'" title="'+ theFile.name + '" style="padding: 0 15px;" width="75" height="67" />');