php 如何在上传图片时,先预览图片,在点击“提交”后存入数据库 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我想用Ajax来实现,但不知道怎样实现 http://www.google.com.hk/search?gcx=c&sourceid=chrome&ie=UTF-8&q=%E9%A2%84%E8%A7%88%E5%9B%BE%E7%89%87+js http://www.cnblogs.com/cloudgamer/archive/2009/12/22/ImagePreview.html <input type="file" name="link_pic" class="fl file_input" id="tupian" /> <input type="button" class="upload_btn fl" value="上传" onclick="yulan2('tupian');" /><tr style="display:none" id="image"> <td width="100px"> 图片预览</td> <td><div id="image2"></div></td>JS代码如下:<script>function yulan2(str){ var obj = document.getElementById(str); var str = getPath(obj); document.getElementById('image').style.display=""; var liulanqi = getOs(); if(liulanqi=="Safari") {document.getElementById('image2').innerHTML = "该款浏览器无法正常显示待上传的图片,但不会影响图片的正常上传,若要显示待上传的图片,推荐使用IE浏览器登录本系统!";} else {document.getElementById('image2').innerHTML = "<img src='" + str + "' />";}}function getOs() { var OsObject = ""; if(navigator.userAgent.indexOf("MSIE")>0) { return "MSIE"; } if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){ return "Firefox"; } if(isSafari=navigator.userAgent.indexOf("Safari")>0) { return "Safari"; } if(isCamino=navigator.userAgent.indexOf("Camino")>0){ return "Camino"; } if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0){ return "Gecko"; } } //获取以下即为完整客户端路径function getPath(obj) { if(obj){ if(window.navigator.userAgent.indexOf("MSIE") >= 1) { obj.select(); return document.selection.createRange().text; }else if(window.navigator.userAgent.indexOf("Firefox") >= 1) { if (obj.files) { return obj.files.item(0).getAsDataURL(); } return obj.value; } return obj.value; }} </script>但是Firefox浏览器可以预览图片,但是IE浏览器却不行,该怎么改呢? 感觉不必要吧。预览图片大多用flash来实现。js估计兼容不好弄。上传图片让用户自己截取就好了。jquery有插件。无刷新上传就用iframe实现。 php上传文件到linux空间问题,谢谢 mysql被收购,那phpmyadmin不就玩完了? php 如何读取oracle 中是CLOB类型 求助.WAMP5和XAMPP的异同, 为什么不能录入数据到表格 寻php兼职 寻求CSDN有创意的兄弟,100全送给你!!!!! 这段代码为什么在IE中间可以分成左右量栏,但是在FIREFOX中就不可以呢。我应该怎么该,谢谢 如何发email,配置smtp?帮帮忙! 求大神:要学习什么语言,可以改动ZOL模拟攒机源码? 小弟做了一个小站大家看看 PHP怎样连接Sql Server数据库
<input type="button" class="upload_btn fl" value="上传" onclick="yulan2('tupian');" />
<tr style="display:none" id="image">
<td width="100px"> 图片预览</td>
<td><div id="image2"></div></td>
JS代码如下:<script>
function yulan2(str){
var obj = document.getElementById(str);
var str = getPath(obj);
document.getElementById('image').style.display="";
var liulanqi = getOs();
if(liulanqi=="Safari")
{document.getElementById('image2').innerHTML = "该款浏览器无法正常显示待上传的图片,但不会影响图片的正常上传,若要显示待上传的图片,推荐使用IE浏览器登录本系统!";}
else
{document.getElementById('image2').innerHTML = "<img src='" + str + "' />";}
}
function getOs()
{
var OsObject = "";
if(navigator.userAgent.indexOf("MSIE")>0) {
return "MSIE";
}
if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){
return "Firefox";
}
if(isSafari=navigator.userAgent.indexOf("Safari")>0) {
return "Safari";
}
if(isCamino=navigator.userAgent.indexOf("Camino")>0){
return "Camino";
}
if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0){
return "Gecko";
}
} //获取以下即为完整客户端路径
function getPath(obj) {
if(obj){
if(window.navigator.userAgent.indexOf("MSIE") >= 1) {
obj.select(); return document.selection.createRange().text;
}else if(window.navigator.userAgent.indexOf("Firefox") >= 1) {
if (obj.files) {
return obj.files.item(0).getAsDataURL();
}
return obj.value;
}
return obj.value;
}
}
</script>
但是Firefox浏览器可以预览图片,但是IE浏览器却不行,该怎么改呢?